"{ Package: 'stx:goodies/xmlsuite/xpath' }"
"{ NameSpace: XQuery }"
InsertCommand subclass:#InsertAsLastIntoCommand
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'XQuery-Update Facility'
!
!InsertAsLastIntoCommand methodsFor:'checks'!
checkSourceSequence:anXQuerySequence
| foundNonAttribute |
foundNonAttribute := false.
anXQuerySequence do:
[:seqItem|
self
assert: ((seqItem type == XQuerySequenceItem typeAttribute and:[foundNonAttribute])) not
description:'An attribute found after non-attribute (see section 2.3.1.)'.
foundNonAttribute := (seqItem type == XQuerySequenceItem typeAttribute) not]
"Modified: / 21-11-2007 / 11:24:56 / janfrog"
!
checkTargetSequence: anXQuerySequence
self
assert: anXQuerySequence containsSingleElement & anXQuerySequence first type == XQuerySequenceItem typeNode
description: 'target must be a single element or document node (see section 2.3.1.)'.
"Modified: / 21-11-2007 / 11:26:23 / janfrog"
! !
!InsertAsLastIntoCommand methodsFor:'executing'!
execute
"Superclass says that I am responsible to implement this method"
self sourceSequence
do:[:node|self insert: node asLastInto: self targetSequence first]
"Created: / 21-11-2007 / 11:22:31 / janfrog"
! !
!InsertAsLastIntoCommand methodsFor:'inserting'!
insert:sourceNode asLastInto:targetNode
|importedSourceNodeId|
importedSourceNodeId := targetNode documentAdaptor
importForeingNode: sourceNode item nodeId
adaptor: sourceNode documentAdaptor.
(sourceNode type == XQuerySequenceItem typeAttribute) ifTrue:[
targetNode documentAdaptor updInsertAttribute: importedSourceNodeId into: targetNode item nodeId
] ifFalse:[
targetNode documentAdaptor updInsert:importedSourceNodeId asLastInto:targetNode item nodeId
]
"Created: / 21-11-2007 / 11:28:21 / janfrog"
! !
!InsertAsLastIntoCommand class methodsFor:'documentation'!
version
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xpath/XQuery__InsertAsLastIntoCommand.st,v 1.1 2007-11-22 21:58:23 vranyj1 Exp $'
! !