0
|
1 |
"{ Package: 'stx:goodies/xmlsuite' }"
|
|
2 |
|
|
3 |
"{ NameSpace: XMLv2 }"
|
|
4 |
|
|
5 |
NamedNodeMap subclass:#Attributes
|
|
6 |
instanceVariableNames:'ownerElement'
|
|
7 |
classVariableNames:'EmptyAttributes'
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'XML Suite-SAX2'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!Attributes class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
empty
|
|
16 |
|
|
17 |
"EmptyAttributes ifNil:[EmptyAttributes := self new].
|
|
18 |
^EmptyAttributes"
|
|
19 |
^self new:0
|
|
20 |
|
|
21 |
"Created: / 16-04-2005 / 20:12:53 / janfrog"
|
|
22 |
"Modified: / 12-04-2007 / 10:45:31 / janfrog"
|
|
23 |
! !
|
|
24 |
|
|
25 |
!Attributes methodsFor:'SAX2 interface'!
|
|
26 |
|
|
27 |
getIndexByQualifiedName:qName
|
|
28 |
|
|
29 |
self keysAndValuesDo:[:index :attribute |
|
|
30 |
attribute qualifiedName = qName ifTrue:[^index]
|
|
31 |
].
|
|
32 |
^-1 "Should return 0?"
|
|
33 |
|
|
34 |
"Created: / 16-04-2005 / 20:15:45 / janfrog"
|
|
35 |
"Modified: / 11-05-2005 / 19:35:10 / janfrog"
|
|
36 |
!
|
|
37 |
|
|
38 |
getIndexByURI:uri localName:localName
|
|
39 |
|
|
40 |
self keysAndValuesDo:[:index :attr |
|
|
41 |
((attr ns = uri) and:[attr name = localName]) ifTrue:[^index]
|
|
42 |
].
|
|
43 |
^-1 "Should return 0?"
|
|
44 |
|
|
45 |
"Created: / 16-04-2005 / 20:17:54 / janfrog"
|
|
46 |
"Modified: / 11-05-2005 / 19:35:40 / janfrog"
|
|
47 |
!
|
|
48 |
|
|
49 |
getLength
|
|
50 |
|
|
51 |
^self size
|
|
52 |
|
|
53 |
"Created: / 16-04-2005 / 20:18:26 / janfrog"
|
|
54 |
"Modified: / 11-05-2005 / 19:37:25 / janfrog"
|
|
55 |
!
|
|
56 |
|
|
57 |
getLocalName:index
|
|
58 |
|
|
59 |
^(self at:index) name
|
|
60 |
|
|
61 |
"Created: / 16-04-2005 / 20:19:28 / janfrog"
|
|
62 |
"Modified: / 11-05-2005 / 19:37:31 / janfrog"
|
|
63 |
!
|
|
64 |
|
|
65 |
getQName:index
|
|
66 |
|
|
67 |
^(self at:index) qualifiedName
|
|
68 |
|
|
69 |
"Created: / 16-04-2005 / 20:19:41 / janfrog"
|
|
70 |
"Modified: / 11-05-2005 / 19:37:39 / janfrog"
|
|
71 |
!
|
|
72 |
|
|
73 |
getTypeByIndex:index
|
|
74 |
|
|
75 |
^'NMToken'
|
|
76 |
|
|
77 |
"Created: / 16-04-2005 / 20:20:46 / janfrog"
|
|
78 |
!
|
|
79 |
|
|
80 |
getTypeByQualifiedName:qName
|
|
81 |
|
|
82 |
^'NMToken'
|
|
83 |
|
|
84 |
"Created: / 16-04-2005 / 20:21:02 / janfrog"
|
|
85 |
!
|
|
86 |
|
|
87 |
getTypeByURI:uri localName:localName
|
|
88 |
|
|
89 |
^'NMToken'
|
|
90 |
|
|
91 |
"Created: / 16-04-2005 / 20:21:17 / janfrog"
|
|
92 |
!
|
|
93 |
|
|
94 |
getURI:index
|
|
95 |
|
|
96 |
(self at:index) ns
|
|
97 |
|
|
98 |
"Created: / 16-04-2005 / 20:22:49 / janfrog"
|
|
99 |
"Modified: / 11-05-2005 / 19:38:05 / janfrog"
|
|
100 |
!
|
|
101 |
|
|
102 |
getValueByIndex:index
|
|
103 |
|
|
104 |
(self at:index) value
|
|
105 |
|
|
106 |
"Created: / 16-04-2005 / 20:23:15 / janfrog"
|
|
107 |
"Modified: / 11-05-2005 / 19:38:13 / janfrog"
|
|
108 |
!
|
|
109 |
|
|
110 |
getValueByQualifiedName:qName
|
|
111 |
|
|
112 |
self do:[:att | att qualifiedName = qName ifTrue:[^att value]].
|
|
113 |
^nil
|
|
114 |
|
|
115 |
"Created: / 16-04-2005 / 20:24:19 / janfrog"
|
|
116 |
"Modified: / 11-05-2005 / 19:38:21 / janfrog"
|
|
117 |
!
|
|
118 |
|
|
119 |
getValueByURI:uri localName:localName
|
|
120 |
|attr|
|
|
121 |
|
|
122 |
^ (attr := self nodesWithURI:uri localName:localName)
|
|
123 |
ifNotNil:[ attr value ]
|
|
124 |
|
|
125 |
"Created: / 16-04-2005 / 20:24:57 / janfrog"
|
|
126 |
"Modified: / 16-06-2005 / 15:53:47 / janfrog"
|
|
127 |
! !
|
|
128 |
|
|
129 |
!Attributes methodsFor:'SAX2 interface - extensions'!
|
|
130 |
|
|
131 |
getValueByLocalName:localName
|
|
132 |
|attr|
|
|
133 |
|
|
134 |
^ (attr := self nodesWithLocalName:localName) ifNotNil:[ attr value ]
|
|
135 |
|
|
136 |
"Created: / 16-06-2005 / 14:02:58 / janfrog"
|
|
137 |
"Modified: / 16-06-2005 / 15:54:32 / janfrog"
|
|
138 |
! !
|
|
139 |
|
|
140 |
!Attributes methodsFor:'accessing'!
|
|
141 |
|
|
142 |
basicAt: index put: anAttr
|
|
143 |
|
|
144 |
"Quite dirty hack"
|
|
145 |
|
|
146 |
| oldElement |
|
|
147 |
self ensureIsAttrOrNil: anAttr.
|
|
148 |
oldElement := self basicAt: index.
|
|
149 |
self ensureIsAttrOrNil: oldElement.
|
|
150 |
oldElement ifNotNil:[oldElement setOwnerElement: nil].
|
|
151 |
anAttr setOwnerElement: ownerElement.
|
|
152 |
^super basicAt: index put: anAttr
|
|
153 |
|
|
154 |
"Created: / 12-11-2007 / 18:15:10 / janfrog"
|
|
155 |
!
|
|
156 |
|
|
157 |
ownerElement
|
|
158 |
^ ownerElement
|
|
159 |
|
|
160 |
"Created: / 12-11-2007 / 18:14:52 / janfrog"
|
|
161 |
! !
|
|
162 |
|
|
163 |
!Attributes methodsFor:'error handling'!
|
|
164 |
|
|
165 |
ensureIsAttrOrNil: anAttrOrNil
|
|
166 |
|
|
167 |
anAttrOrNil ifNil:[^self].
|
|
168 |
(anAttrOrNil isKindOf: Attr) ifFalse:
|
|
169 |
[self error:'Not an instance of XMLv2::Attr: ', anAttrOrNil printString].
|
|
170 |
|
|
171 |
"Created: / 12-11-2007 / 18:35:02 / janfrog"
|
|
172 |
! !
|
|
173 |
|
|
174 |
!Attributes methodsFor:'initialization'!
|
|
175 |
|
|
176 |
setOwnerElement: anElementOrNil
|
|
177 |
|
|
178 |
ownerElement := anElementOrNil .
|
|
179 |
self do:[:attr|attr setOwnerElement: anElementOrNil].
|
|
180 |
|
|
181 |
"Created: / 12-11-2007 / 18:40:18 / janfrog"
|
|
182 |
! !
|
|
183 |
|
|
184 |
!Attributes class methodsFor:'documentation'!
|
|
185 |
|
|
186 |
version
|
|
187 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/XMLv2__Attributes.st,v 1.4 2007-11-12 20:23:36 vranyj1 Exp $'
|
|
188 |
! !
|