0
|
1 |
"{ Package: 'stx:goodies/xmlsuite/xquery' }"
|
|
2 |
|
|
3 |
"{ NameSpace: XQuery }"
|
|
4 |
|
|
5 |
OrderedCollection subclass:#XQuerySequence
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'XQuery-Interpreter'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!XQuerySequence class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
withAttribute: node
|
|
16 |
|
|
17 |
^self with: (XQuerySequenceItem withAttribute: node)
|
|
18 |
|
|
19 |
"Created: / 21-03-2007 / 14:31:17 / janfrog"
|
|
20 |
!
|
|
21 |
|
|
22 |
withBoolean: aBoolean
|
|
23 |
|
|
24 |
^self with:(XQuerySequenceItem withBoolean:aBoolean)
|
|
25 |
|
|
26 |
"Created: / 21-03-2007 / 13:49:23 / janfrog"
|
|
27 |
!
|
|
28 |
|
|
29 |
withNode: node
|
|
30 |
|
|
31 |
^self with: (XQuerySequenceItem withNode: node)
|
|
32 |
|
|
33 |
"Created: / 21-03-2007 / 14:31:17 / janfrog"
|
|
34 |
!
|
|
35 |
|
|
36 |
withNodes: nodes
|
|
37 |
|
|
38 |
^self withAll: (nodes collect:[:node|XQuerySequenceItem withNode: node])
|
|
39 |
|
|
40 |
"Created: / 18-11-2007 / 08:01:07 / janfrog"
|
|
41 |
!
|
|
42 |
|
|
43 |
withNumber: aNumber
|
|
44 |
|
|
45 |
^self with: (XQuerySequenceItem withNumber: aNumber)
|
|
46 |
|
|
47 |
"Created: / 21-03-2007 / 13:49:23 / janfrog"
|
|
48 |
!
|
|
49 |
|
|
50 |
withNumbers: aCollection"of numbers"
|
|
51 |
|
|
52 |
^self withAll:
|
|
53 |
(aCollection collect:
|
|
54 |
[:num|XQuerySequenceItem withNumber: num])
|
|
55 |
|
|
56 |
"Created: / 21-03-2007 / 14:23:43 / janfrog"
|
|
57 |
!
|
|
58 |
|
|
59 |
withString: string
|
|
60 |
|
|
61 |
^self with:(XQuerySequenceItem withString:string)
|
|
62 |
|
|
63 |
"Created: / 21-03-2007 / 15:45:37 / janfrog"
|
|
64 |
"Modified: / 21-03-2007 / 19:11:37 / janfrog"
|
|
65 |
!
|
|
66 |
|
|
67 |
withStrings: stringCollection
|
|
68 |
|
|
69 |
^self withAll:
|
|
70 |
(stringCollection collect:
|
|
71 |
[:str|XQuerySequenceItem withString: str])
|
|
72 |
|
|
73 |
"Created: / 29-08-2007 / 10:29:19 / janfrog"
|
|
74 |
!
|
|
75 |
|
|
76 |
withText: string
|
|
77 |
|
|
78 |
^self with:(XQuerySequenceItem withText:string)
|
|
79 |
|
|
80 |
"Created: / 28-03-2007 / 22:49:53 / janfrog"
|
|
81 |
! !
|
|
82 |
|
|
83 |
!XQuerySequence methodsFor:'converting'!
|
|
84 |
|
|
85 |
asInteger
|
|
86 |
|
|
87 |
self assert:self containsSingleInteger.
|
|
88 |
^self first item value asInteger
|
|
89 |
|
|
90 |
"Created: / 21-03-2007 / 20:24:16 / janfrog"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!XQuerySequence methodsFor:'evaluation'!
|
|
94 |
|
|
95 |
effectiveBooleanValue
|
|
96 |
"
|
|
97 |
If $arg is the empty sequence, fn:boolean returns false.
|
|
98 |
|
|
99 |
If $arg is a sequence whose first item is a node, fn:boolean returns true.
|
|
100 |
|
|
101 |
If $arg is a singleton value of type xs:boolean or a derived from xs:boolean, fn:boolean returns $arg.
|
|
102 |
|
|
103 |
If $arg is a singleton value of type xs:string or a type derived from xs:string,
|
|
104 |
xs:anyURI or a type derived from xs:anyURI or xs:untypedAtomic, fn:boolean returns false
|
|
105 |
if the operand value has zero length; otherwise it returns true.
|
|
106 |
|
|
107 |
If $arg is a singleton value of any numeric type or a type derived from a numeric type,
|
|
108 |
fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.
|
|
109 |
|
|
110 |
In all other cases, fn:boolean raises a type error [err:FORG0006]."
|
|
111 |
|
|
112 |
self isEmpty ifTrue:[
|
|
113 |
^ false
|
|
114 |
].
|
|
115 |
(self first type isSubtypeOf:XQuerySequenceItem typeNode) ifTrue:[
|
|
116 |
^ true
|
|
117 |
].
|
|
118 |
((self size = 1)
|
|
119 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSBoolean ])
|
|
120 |
ifTrue:[ ^ self first item ].
|
|
121 |
((self size = 1)
|
|
122 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSString ])
|
|
123 |
ifTrue:[ ^ self first item isEmpty not ].
|
|
124 |
((self size = 1)
|
|
125 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSDecimal ])
|
|
126 |
ifTrue:[ ^ self first item ~= 0 ].
|
|
127 |
((self size = 1)
|
|
128 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSFloat ])
|
|
129 |
ifTrue:[ ^ self first item ~= 0 ].
|
|
130 |
self error:'err:FORG0006'.
|
|
131 |
^ false
|
|
132 |
|
|
133 |
"Created: / 21-03-2007 / 14:58:03 / janfrog"
|
|
134 |
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
|
|
135 |
! !
|
|
136 |
|
|
137 |
!XQuerySequence methodsFor:'queries'!
|
|
138 |
|
|
139 |
containsSingleAtomicValue
|
|
140 |
|
|
141 |
^self isSingletonSequence
|
|
142 |
and:[self first containsAtomicValue]
|
|
143 |
|
|
144 |
"Created: / 21-11-2007 / 10:31:23 / janfrog"
|
|
145 |
"Modified: / 21-11-2007 / 12:27:18 / janfrog"
|
|
146 |
!
|
|
147 |
|
|
148 |
containsSingleAttribute
|
|
149 |
^ self containsSingleNode
|
|
150 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeAttribute ]
|
|
151 |
|
|
152 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
153 |
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
|
|
154 |
!
|
|
155 |
|
|
156 |
containsSingleDocument
|
|
157 |
^ self size = 1
|
|
158 |
and:[
|
|
159 |
(self first type isSubtypeOf:XQuerySequenceItem typeDocument)
|
|
160 |
|
|
161 |
]
|
|
162 |
|
|
163 |
"Created: / 14-11-2007 / 11:20:27 / janfrog"
|
|
164 |
"Modified: / 05-12-2007 / 15:52:24 / janfrog"
|
|
165 |
!
|
|
166 |
|
|
167 |
containsSingleElement
|
|
168 |
^ self containsSingleNode
|
|
169 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeElement ]
|
|
170 |
|
|
171 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
172 |
"Modified: / 05-12-2007 / 21:55:29 / janfrog"
|
|
173 |
!
|
|
174 |
|
|
175 |
containsSingleElementOrDocument
|
|
176 |
|
|
177 |
^self containsSingleElement
|
|
178 |
or:[self containsSingleDocument].
|
|
179 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
180 |
"Modified: / 05-12-2007 / 21:55:29 / janfrog"
|
|
181 |
!
|
|
182 |
|
|
183 |
containsSingleInteger
|
|
184 |
^ self size = 1
|
|
185 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSInteger ]
|
|
186 |
|
|
187 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
188 |
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
|
|
189 |
!
|
|
190 |
|
|
191 |
containsSingleNode
|
|
192 |
|
|
193 |
^(self size = 1) and:[self first containsNode]
|
|
194 |
|
|
195 |
"Created: / 14-11-2007 / 10:11:45 / janfrog"
|
|
196 |
"Modified: / 21-11-2007 / 09:10:21 / janfrog"
|
|
197 |
!
|
|
198 |
|
|
199 |
containsSingleNumber
|
|
200 |
^ self size = 1
|
|
201 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeNumber ]
|
|
202 |
|
|
203 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
204 |
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
|
|
205 |
!
|
|
206 |
|
|
207 |
containsSingleString
|
|
208 |
^ self size = 1
|
|
209 |
and:[ self first type isSubtypeOf:XQuerySequenceItem typeString ]
|
|
210 |
|
|
211 |
"Created: / 21-03-2007 / 20:25:01 / janfrog"
|
|
212 |
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
|
|
213 |
!
|
|
214 |
|
|
215 |
containsSingleText
|
|
216 |
|
|
217 |
^self containsSingleNode and:[self first item isTextNode]
|
|
218 |
|
|
219 |
"Created: / 21-11-2007 / 10:06:34 / janfrog"
|
|
220 |
!
|
|
221 |
|
|
222 |
containsSingleTextOrAtomicValue
|
|
223 |
|
|
224 |
^self containsSingleAtomicValue or:[self containsSingleText]
|
|
225 |
|
|
226 |
"Created: / 21-11-2007 / 10:30:27 / janfrog"
|
|
227 |
"Modified: / 21-11-2007 / 12:27:26 / janfrog"
|
|
228 |
! !
|
|
229 |
|
|
230 |
!XQuerySequence methodsFor:'testing'!
|
|
231 |
|
|
232 |
isSingletonSequence
|
|
233 |
|
|
234 |
^self size = 1
|
|
235 |
|
|
236 |
"Created: / 21-11-2007 / 12:26:01 / janfrog"
|
|
237 |
! !
|
|
238 |
|
|
239 |
!XQuerySequence class methodsFor:'documentation'!
|
|
240 |
|
|
241 |
version
|
|
242 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__XQuerySequence.st,v 1.13 2008-01-09 14:08:00 wrobll1 Exp $'
|
|
243 |
! !
|