0
|
1 |
"{ Package: 'stx:goodies/xmlsuite/xquery' }"
|
|
2 |
|
|
3 |
"{ NameSpace: XQuery }"
|
|
4 |
|
|
5 |
XMLv2::XPathDocumentAdaptor subclass:#XPathDocumentAdaptorProxy
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'XQuery-Executor'
|
|
10 |
!
|
|
11 |
|
|
12 |
XPathDocumentAdaptorProxy class instanceVariableNames:'instance'
|
|
13 |
|
|
14 |
"
|
|
15 |
No other class instance variables are inherited by this class.
|
|
16 |
"
|
|
17 |
!
|
|
18 |
|
|
19 |
|
|
20 |
!XPathDocumentAdaptorProxy class methodsFor:'accessing'!
|
|
21 |
|
|
22 |
documentClass
|
|
23 |
|
|
24 |
^self
|
|
25 |
|
|
26 |
"Created: / 02-11-2006 / 11:51:56 / ked"
|
|
27 |
"Modified: / 03-11-2006 / 11:29:24 / ked"
|
|
28 |
!
|
|
29 |
|
|
30 |
instance
|
|
31 |
instance ifNil:[
|
|
32 |
instance := self new.
|
|
33 |
].
|
|
34 |
^ instance
|
|
35 |
|
|
36 |
"Created: / 03-11-2006 / 11:19:39 / ked"
|
|
37 |
! !
|
|
38 |
|
|
39 |
!XPathDocumentAdaptorProxy methodsFor:'checking'!
|
|
40 |
|
|
41 |
ensureIsValidNodeId:anObject
|
|
42 |
|
|
43 |
^self
|
|
44 |
|
|
45 |
"Created: / 03-11-2006 / 11:28:23 / ked"
|
|
46 |
!
|
|
47 |
|
|
48 |
ensureNotReleased
|
|
49 |
|
|
50 |
^self
|
|
51 |
|
|
52 |
"Created: / 03-11-2006 / 12:19:28 / ked"
|
|
53 |
! !
|
|
54 |
|
|
55 |
!XPathDocumentAdaptorProxy methodsFor:'private'!
|
|
56 |
|
|
57 |
wrapNodeCollection: aNodeCollection withDocumentAdaptor: aDocumentAdaptor
|
|
58 |
|
|
59 |
^aNodeCollection collect:[:item | XQueryAccessedNode new nodeId: item; documentAdaptor: aDocumentAdaptor ].
|
|
60 |
|
|
61 |
"Created: / 03-11-2006 / 20:52:38 / ked"
|
|
62 |
!
|
|
63 |
|
|
64 |
wrapSingleNode: aNodeId withDocumentAdaptor: aDocumentAdaptor
|
|
65 |
aNodeId ifNil:[
|
|
66 |
^nil.
|
|
67 |
].
|
|
68 |
|
|
69 |
^XQueryAccessedNode new nodeId: aNodeId; documentAdaptor: aDocumentAdaptor.
|
|
70 |
|
|
71 |
"Created: / 03-11-2006 / 20:52:29 / ked"
|
|
72 |
! !
|
|
73 |
|
|
74 |
!XPathDocumentAdaptorProxy methodsFor:'resource management'!
|
|
75 |
|
|
76 |
primReleaseResources
|
|
77 |
|
|
78 |
^self
|
|
79 |
|
|
80 |
"Created: / 12-12-2006 / 10:46:25 / janfrog"
|
|
81 |
! !
|
|
82 |
|
|
83 |
!XPathDocumentAdaptorProxy methodsFor:'xpath axes'!
|
|
84 |
|
|
85 |
xpathDocumentOf: aNode
|
|
86 |
|
|
87 |
aNode isXQueryConstructedNode ifTrue:[
|
|
88 |
aNode nodeParent ifNil:[
|
|
89 |
^aNode.
|
|
90 |
] ifNotNil:[
|
|
91 |
^self xpathDocumentOf: aNode nodeParent.
|
|
92 |
].
|
|
93 |
] ifFalse:[
|
|
94 |
aNode constructedParent ifNil:[
|
|
95 |
^self wrapSingleNode:(aNode documentAdaptor document) withDocumentAdaptor:(aNode documentAdaptor).
|
|
96 |
] ifNotNil:[
|
|
97 |
^self xpathDocumentOf: aNode constructedParent.
|
|
98 |
].
|
|
99 |
].
|
|
100 |
|
|
101 |
"Modified: / 03-11-2006 / 20:53:39 / ked"
|
|
102 |
"Created: / 14-12-2006 / 23:25:54 / janfrog"
|
|
103 |
! !
|
|
104 |
|
|
105 |
!XPathDocumentAdaptorProxy methodsFor:'xpath primitives'!
|
|
106 |
|
|
107 |
primXpathAttributeOf: aNode
|
|
108 |
|
|
109 |
aNode isXQueryConstructedNode ifTrue:[
|
|
110 |
^aNode nodeAttributes.
|
|
111 |
] ifFalse:[
|
|
112 |
aNode constructedAttributes ifNil:[
|
|
113 |
aNode constructedParent ifNil:[
|
|
114 |
^self wrapNodeCollection:(aNode documentAdaptor xpathAttributeOf: aNode nodeId) withDocumentAdaptor:(aNode documentAdaptor).
|
|
115 |
] ifNotNil:[
|
|
116 |
aNode constructedAttributes: OrderedCollection new.
|
|
117 |
|
|
118 |
^(self wrapNodeCollection:(aNode documentAdaptor xpathAttributeOf: aNode nodeId) withDocumentAdaptor:(aNode documentAdaptor))
|
|
119 |
collect: [:node | aNode constructedAttributes add: node. node constructedParent: aNode. ].
|
|
120 |
].
|
|
121 |
] ifNotNil:[
|
|
122 |
^aNode constructedAttributes.
|
|
123 |
].
|
|
124 |
].
|
|
125 |
|
|
126 |
"Modified: / 03-11-2006 / 20:53:17 / ked"
|
|
127 |
"Created: / 14-12-2006 / 23:25:30 / janfrog"
|
|
128 |
!
|
|
129 |
|
|
130 |
primXpathAttributeValueOf: aNode
|
|
131 |
|
|
132 |
aNode isXQueryConstructedNode ifTrue:[
|
|
133 |
^aNode nodeValue.
|
|
134 |
] ifFalse:[
|
|
135 |
^aNode documentAdaptor xpathAttributeValueOf: aNode nodeId.
|
|
136 |
].
|
|
137 |
|
|
138 |
"Modified: / 03-11-2006 / 20:49:26 / ked"
|
|
139 |
"Created: / 14-12-2006 / 23:27:59 / janfrog"
|
|
140 |
!
|
|
141 |
|
|
142 |
primXpathChildOf: aNode
|
|
143 |
|
|
144 |
aNode isXQueryConstructedNode ifTrue:[
|
|
145 |
^aNode nodeChildren.
|
|
146 |
] ifFalse:[
|
|
147 |
aNode constructedChildren ifNil:[
|
|
148 |
aNode constructedParent ifNil:[
|
|
149 |
^(self wrapNodeCollection:(aNode documentAdaptor xpathChildOf: aNode nodeId) withDocumentAdaptor:(aNode documentAdaptor))
|
|
150 |
select: [:node | node xpathIsIgnorableText not ].
|
|
151 |
] ifNotNil:[
|
|
152 |
aNode constructedChildren: OrderedCollection new.
|
|
153 |
|
|
154 |
^((self wrapNodeCollection:(aNode documentAdaptor xpathChildOf: aNode nodeId) withDocumentAdaptor:(aNode documentAdaptor))
|
|
155 |
select: [:node | node xpathIsIgnorableText not ])
|
|
156 |
collect: [:node | aNode constructedChildren add: node. node constructedParent: aNode. ].
|
|
157 |
].
|
|
158 |
] ifNotNil:[
|
|
159 |
^aNode constructedChildren.
|
|
160 |
].
|
|
161 |
].
|
|
162 |
|
|
163 |
"Modified: / 03-12-2006 / 12:41:52 / ked"
|
|
164 |
"Created: / 14-12-2006 / 23:25:42 / janfrog"
|
|
165 |
!
|
|
166 |
|
|
167 |
primXpathElementValueOf: aNode
|
|
168 |
|
|
169 |
aNode isXQueryConstructedNode ifTrue:[
|
|
170 |
^aNode nodeValue.
|
|
171 |
] ifFalse:[
|
|
172 |
^aNode documentAdaptor xpathElementValueOf: aNode nodeId.
|
|
173 |
].
|
|
174 |
|
|
175 |
"Modified: / 03-11-2006 / 20:49:46 / ked"
|
|
176 |
"Created: / 14-12-2006 / 23:28:05 / janfrog"
|
|
177 |
!
|
|
178 |
|
|
179 |
primXpathIsAttribute: aNode
|
|
180 |
|
|
181 |
aNode isXQueryConstructedNode ifTrue:[
|
|
182 |
^aNode nodeType = XQueryConstructedNode nodeTypeAttribute.
|
|
183 |
] ifFalse:[
|
|
184 |
^aNode documentAdaptor xpathIsAttribute: aNode nodeId.
|
|
185 |
].
|
|
186 |
|
|
187 |
"Created: / 14-12-2006 / 23:26:47 / janfrog"
|
|
188 |
!
|
|
189 |
|
|
190 |
primXpathIsDocument: aNode
|
|
191 |
|
|
192 |
aNode isXQueryConstructedNode ifTrue:[
|
|
193 |
"aNode nodeParent ifNil:[^true. ]."
|
|
194 |
^aNode nodeType = XQueryConstructedNode nodeTypeDocument.
|
|
195 |
] ifFalse:[
|
|
196 |
^aNode documentAdaptor xpathIsDocument: aNode nodeId.
|
|
197 |
].
|
|
198 |
|
|
199 |
"Modified: / 03-11-2006 / 14:27:32 / ked"
|
|
200 |
"Created: / 14-12-2006 / 23:26:59 / janfrog"
|
|
201 |
"Modified: / 20-03-2007 / 22:36:39 / janfrog"
|
|
202 |
!
|
|
203 |
|
|
204 |
primXpathIsDocumentFragment:aNode
|
|
205 |
"Superclass says that I am responsible to implement this method"
|
|
206 |
|
|
207 |
aNode isXQueryConstructedNode ifTrue:[
|
|
208 |
"aNode nodeParent ifNil:[^true. ]."
|
|
209 |
"^aNode nodeType = XQueryConstructedNode nodeTypeDocumentFragment."
|
|
210 |
^false
|
|
211 |
] ifFalse:[
|
|
212 |
^aNode documentAdaptor xpathIsDocumentFragment: aNode nodeId.
|
|
213 |
].
|
|
214 |
|
|
215 |
"Created: / 10-08-2007 / 09:16:21 / janfrog"
|
|
216 |
!
|
|
217 |
|
|
218 |
primXpathIsElement: aNode
|
|
219 |
|
|
220 |
aNode isXQueryConstructedNode ifTrue:[
|
|
221 |
^aNode nodeType = XQueryConstructedNode nodeTypeElement.
|
|
222 |
] ifFalse:[
|
|
223 |
^aNode documentAdaptor xpathIsElement: aNode nodeId.
|
|
224 |
].
|
|
225 |
|
|
226 |
"Created: / 14-12-2006 / 23:27:30 / janfrog"
|
|
227 |
!
|
|
228 |
|
|
229 |
primXpathIsText: aNode
|
|
230 |
|
|
231 |
aNode isXQueryConstructedNode ifTrue:[
|
|
232 |
^aNode nodeType = XQueryConstructedNode nodeTypeText.
|
|
233 |
] ifFalse:[
|
|
234 |
^aNode documentAdaptor xpathIsText: aNode nodeId.
|
|
235 |
].
|
|
236 |
|
|
237 |
"Created: / 14-12-2006 / 23:27:34 / janfrog"
|
|
238 |
!
|
|
239 |
|
|
240 |
primXpathLocalNameOf: aNode
|
|
241 |
|
|
242 |
aNode isXQueryConstructedNode ifTrue:[
|
|
243 |
^aNode nodeName localName.
|
|
244 |
] ifFalse:[
|
|
245 |
^aNode documentAdaptor xpathLocalNameOf: aNode nodeId.
|
|
246 |
].
|
|
247 |
|
|
248 |
"Modified: / 03-11-2006 / 20:49:58 / ked"
|
|
249 |
"Created: / 14-12-2006 / 23:28:12 / janfrog"
|
|
250 |
"Modified: / 24-12-2006 / 16:13:17 / janfrog"
|
|
251 |
!
|
|
252 |
|
|
253 |
primXpathNameOf: aNode
|
|
254 |
|
|
255 |
aNode isXQueryConstructedNode ifTrue:[
|
|
256 |
^aNode nodeName qualifiedName.
|
|
257 |
] ifFalse:[
|
|
258 |
^aNode documentAdaptor xpathNameOf: aNode nodeId.
|
|
259 |
].
|
|
260 |
|
|
261 |
"Modified: / 08-11-2006 / 12:55:29 / ked"
|
|
262 |
"Created: / 14-12-2006 / 23:27:50 / janfrog"
|
|
263 |
"Modified: / 24-12-2006 / 16:12:37 / janfrog"
|
|
264 |
!
|
|
265 |
|
|
266 |
primXpathNamespaceOf: aNode
|
|
267 |
|
|
268 |
aNode isXQueryConstructedNode ifTrue:[
|
|
269 |
^aNode nodeName ns.
|
|
270 |
] ifFalse:[
|
|
271 |
^aNode documentAdaptor xpathNamespaceOf: aNode nodeId.
|
|
272 |
].
|
|
273 |
|
|
274 |
"Modified: / 03-11-2006 / 20:50:06 / ked"
|
|
275 |
"Created: / 14-12-2006 / 23:28:18 / janfrog"
|
|
276 |
"Modified: / 24-12-2006 / 16:13:08 / janfrog"
|
|
277 |
!
|
|
278 |
|
|
279 |
primXpathParentOf: aNode
|
|
280 |
|
|
281 |
aNode isXQueryConstructedNode ifTrue:[
|
|
282 |
^aNode nodeParent.
|
|
283 |
] ifFalse:[
|
|
284 |
aNode constructedParent ifNil:[
|
|
285 |
^self wrapSingleNode:(aNode documentAdaptor xpathParentOf: aNode nodeId) withDocumentAdaptor:(aNode documentAdaptor).
|
|
286 |
] ifNotNil:[
|
|
287 |
^aNode constructedParent
|
|
288 |
].
|
|
289 |
].
|
|
290 |
|
|
291 |
"Modified: / 03-11-2006 / 20:53:48 / ked"
|
|
292 |
"Created: / 14-12-2006 / 23:25:58 / janfrog"
|
|
293 |
!
|
|
294 |
|
|
295 |
primXpathTextValueOf: aNode
|
|
296 |
|
|
297 |
aNode isXQueryConstructedNode ifTrue:[
|
|
298 |
^aNode nodeValue.
|
|
299 |
] ifFalse:[
|
|
300 |
^aNode documentAdaptor xpathTextValueOf: aNode nodeId.
|
|
301 |
].
|
|
302 |
|
|
303 |
"Modified: / 03-11-2006 / 20:50:12 / ked"
|
|
304 |
"Created: / 14-12-2006 / 23:28:26 / janfrog"
|
|
305 |
! !
|
|
306 |
|
|
307 |
!XPathDocumentAdaptorProxy class methodsFor:'documentation'!
|
|
308 |
|
|
309 |
version
|
|
310 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__XPathDocumentAdaptorProxy.st,v 1.6 2007-08-10 07:36:50 vranyj1 Exp $'
|
|
311 |
! !
|