"{ Package: 'stx:goodies/xmlsuite/xquery' }"
"{ NameSpace: XQuery }"
OrderedCollection subclass:#XQuerySequence
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'XQuery-Interpreter'
!
!XQuerySequence class methodsFor:'instance creation'!
withAttribute: node
^self with: (XQuerySequenceItem withAttribute: node)
"Created: / 21-03-2007 / 14:31:17 / janfrog"
!
withBoolean: aBoolean
^self with:(XQuerySequenceItem withBoolean:aBoolean)
"Created: / 21-03-2007 / 13:49:23 / janfrog"
!
withNode: node
^self with: (XQuerySequenceItem withNode: node)
"Created: / 21-03-2007 / 14:31:17 / janfrog"
!
withNodes: nodes
^self withAll: (nodes collect:[:node|XQuerySequenceItem withNode: node])
"Created: / 18-11-2007 / 08:01:07 / janfrog"
!
withNumber: aNumber
^self with: (XQuerySequenceItem withNumber: aNumber)
"Created: / 21-03-2007 / 13:49:23 / janfrog"
!
withNumbers: aCollection"of numbers"
^self withAll:
(aCollection collect:
[:num|XQuerySequenceItem withNumber: num])
"Created: / 21-03-2007 / 14:23:43 / janfrog"
!
withString: string
^self with:(XQuerySequenceItem withString:string)
"Created: / 21-03-2007 / 15:45:37 / janfrog"
"Modified: / 21-03-2007 / 19:11:37 / janfrog"
!
withStrings: stringCollection
^self withAll:
(stringCollection collect:
[:str|XQuerySequenceItem withString: str])
"Created: / 29-08-2007 / 10:29:19 / janfrog"
!
withText: string
^self with:(XQuerySequenceItem withText:string)
"Created: / 28-03-2007 / 22:49:53 / janfrog"
! !
!XQuerySequence methodsFor:'converting'!
asInteger
self assert:self containsSingleInteger.
^self first item value asInteger
"Created: / 21-03-2007 / 20:24:16 / janfrog"
! !
!XQuerySequence methodsFor:'evaluation'!
effectiveBooleanValue
"
If $arg is the empty sequence, fn:boolean returns false.
If $arg is a sequence whose first item is a node, fn:boolean returns true.
If $arg is a singleton value of type xs:boolean or a derived from xs:boolean, fn:boolean returns $arg.
If $arg is a singleton value of type xs:string or a type derived from xs:string,
xs:anyURI or a type derived from xs:anyURI or xs:untypedAtomic, fn:boolean returns false
if the operand value has zero length; otherwise it returns true.
If $arg is a singleton value of any numeric type or a type derived from a numeric type,
fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.
In all other cases, fn:boolean raises a type error [err:FORG0006]."
self isEmpty ifTrue:[
^ false
].
(self first type isSubtypeOf:XQuerySequenceItem typeNode) ifTrue:[
^ true
].
((self size = 1)
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSBoolean ])
ifTrue:[ ^ self first item ].
((self size = 1)
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSString ])
ifTrue:[ ^ self first item isEmpty not ].
((self size = 1)
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSDecimal ])
ifTrue:[ ^ self first item ~= 0 ].
((self size = 1)
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSFloat ])
ifTrue:[ ^ self first item ~= 0 ].
self error:'err:FORG0006'.
^ false
"Created: / 21-03-2007 / 14:58:03 / janfrog"
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
! !
!XQuerySequence methodsFor:'queries'!
containsSingleAtomicValue
^self isSingletonSequence
and:[self first containsAtomicValue]
"Created: / 21-11-2007 / 10:31:23 / janfrog"
"Modified: / 21-11-2007 / 12:27:18 / janfrog"
!
containsSingleAttribute
^ self containsSingleNode
and:[ self first type isSubtypeOf:XQuerySequenceItem typeAttribute ]
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
!
containsSingleDocument
^ self size = 1
and:[
(self first type isSubtypeOf:XQuerySequenceItem typeDocument)
]
"Created: / 14-11-2007 / 11:20:27 / janfrog"
"Modified: / 05-12-2007 / 15:52:24 / janfrog"
!
containsSingleElement
^ self containsSingleNode
and:[ self first type isSubtypeOf:XQuerySequenceItem typeElement ]
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 21:55:29 / janfrog"
!
containsSingleElementOrDocument
^self containsSingleElement
or:[self containsSingleDocument].
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 21:55:29 / janfrog"
!
containsSingleInteger
^ self size = 1
and:[ self first type isSubtypeOf:XQuerySequenceItem typeXSInteger ]
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
!
containsSingleNode
^(self size = 1) and:[self first containsNode]
"Created: / 14-11-2007 / 10:11:45 / janfrog"
"Modified: / 21-11-2007 / 09:10:21 / janfrog"
!
containsSingleNumber
^ self size = 1
and:[ self first type isSubtypeOf:XQuerySequenceItem typeNumber ]
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
!
containsSingleString
^ self size = 1
and:[ self first type isSubtypeOf:XQuerySequenceItem typeString ]
"Created: / 21-03-2007 / 20:25:01 / janfrog"
"Modified: / 05-12-2007 / 15:50:51 / janfrog"
!
containsSingleText
^self containsSingleNode and:[self first item isTextNode]
"Created: / 21-11-2007 / 10:06:34 / janfrog"
!
containsSingleTextOrAtomicValue
^self containsSingleAtomicValue or:[self containsSingleText]
"Created: / 21-11-2007 / 10:30:27 / janfrog"
"Modified: / 21-11-2007 / 12:27:26 / janfrog"
! !
!XQuerySequence methodsFor:'testing'!
isSingletonSequence
^self size = 1
"Created: / 21-11-2007 / 12:26:01 / janfrog"
! !
!XQuerySequence class methodsFor:'documentation'!
version
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__XQuerySequence.st,v 1.13 2008-01-09 14:08:00 wrobll1 Exp $'
! !