"{ Package: 'stx:goodies/xmlsuite/xpath' }"
"{ NameSpace: XQuery }"
InsertCommand subclass:#InsertIntoCommand
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'XQuery-Update Facility'
!
!InsertIntoCommand 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:25:04 / 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:25:56 / janfrog"
! !
!InsertIntoCommand methodsFor:'executing'!
execute
"Superclass says that I am responsible to implement this method"
self sourceSequence
do:[:node|self insert: node into: self targetSequence first]
"Created: / 21-11-2007 / 11:23:12 / janfrog"
! !
!InsertIntoCommand methodsFor:'inserting'!
insert:sourceNode into: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 into: targetNode item nodeId
]
"Created: / 21-11-2007 / 11:29:01 / janfrog"
"Modified: / 21-11-2007 / 12:41:38 / janfrog"
! !
!InsertIntoCommand class methodsFor:'documentation'!
version
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xpath/XQuery__InsertIntoCommand.st,v 1.1 2007-11-22 21:53:40 vranyj1 Exp $'
! !