-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmlstring.txt
executable file
·124 lines (80 loc) · 3.77 KB
/
xmlstring.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
let aeonEntityeventitle = aeonentityAEElement.attributes["Name"] as! String
// seEntityh the tinderbox document for a note whose tinderbox Name attribute value
// matches the current Aeon Event Title in aeonEntityeventtitle
var didWeFindMatchingTbxNote = false
for tbxItemAEElement in self.tinderboxXmlDoc!.root["item"]["item"].all! {
// if this for loop doesn't find a match, it's a new note
for tbxItemAeElementChildA in tbxItemAEElement.children {
if matchForAeonEventTitleWithExistingTbxNoteName(tbxItemAeElementChildA, aeonEntityEventTitle: aeonEntityeventitle) {
didWeFindMatchingTbxNote = true
// the Entity's attributes
for aeonAttributeElement in aeonEntityAEElement.children {
let matchingTbxAttributeIndex = aeonAeonEntityAttributes.indexOf(aeonAttributeElement.name)
let tbxAttributeNameString = aeonTbxEntityAttributes[matchingTbxAttributeIndex!]
let attribArray = tbxAttributeNameString.componentsSeparatedByString(",")
let tbxAttributeName = attribArray[0]
if let aeonEntityAttributeValue = aeonAttributeElement.value as String? {
// not find the matching aeonEntityxxxx name in tbx
for tbxItemAeElementChildB in tbxItemAeElementChildA.children {
if let name = tbxItemAeElementChildB.attributes["name"] as? String {
if name == tbxAttributeName {
if name == "AeonEntityDescription" {
if tbxItemAeElementChildB.value != aeonEntityAttributeValue { // or other changes were made
var aeonEntityChildTbxXmlElement = AEXMLElement("attribute")
aeonEntityChildTbxXmlElement.addAttribute("name", value: "Badge")
aeonEntityChildTbxXmlElement.value = "label yellow"
tbxItemAeElementChildA.addChild(aeonEntityChildTbxXmlElement)
var text = tbxItemAeElementChildA["text"]
if text.name == "AEXMLError" {
text = AEXMLElement("text")
text.value = "\n\n\n ======================= original value =============== \n\n" + tbxItemAeElementChildB.value!
tbxItemAeElementChildA.addChild(text)
}
var now = getTodayDateString()
var currenttext = text.value
var newtext = currenttext! + "\n\n\n ======================= \(now) =============== \n\n" + aeonEntityAttributeValue
text.value = newtext
}
}
// also update desc if the value was 'no value from aeon timeline'
var trimmedDesc = tbxItemAeElementChildB.value!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
if trimmedDesc.isEmpty {
tbxItemAeElementChildB.value = aeonEntityAttributeValue
}
break
} // if you found a match to update the tbx aeon xxx field with
} // if you got the name
} // for all the attributes on the tbx element
} // if there was value in the aeon element (then find the tbx and update it)
else { //otherwise
// still find the tbx and update it, and you are not currently doing that
for tbxItemAeElementChildB in tbxItemAeElementChildA.children {
if let name = tbxItemAeElementChildB.attributes["name"] as? String {
if name == tbxAttributeName {
var trimmedDesc = tbxItemAeElementChildB.value!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
if !trimmedDesc.isEmpty {
var aeonEntityChildTbxXmlElement = AEXMLElement("attribute")
aeonEntityChildTbxXmlElement.addAttribute("name", value: "Badge")
aeonEntityChildTbxXmlElement.value = "label yellow"
tbxItemAeElementChildA.addChild(aeonEntityChildTbxXmlElement)
}
var text = tbxItemAeElementChildA["text"]
if text.name == "AEXMLError" {
text = AEXMLElement("text")
text.value = "\n\n\n ======================= original value =============== \n\n" + tbxItemAeElementChildB.value!
tbxItemAeElementChildA.addChild(text)
}
// capture b value here add to log roll on text item
if trimmedDesc.isEmpty {
tbxItemAeElementChildB.value = "no value found"
}
break
} // if you found a match to update the tbx aeon xxx field with
} // if you got the name
}
}
}
}// no matching note found, return false
} // for loop
} // for loop
return didWeFindMatchingTbxNote