|
1 "{ Package: 'stx:goodies/xmlsuite/xpath' }" |
|
2 |
|
3 "{ NameSpace: XQuery }" |
|
4 |
|
5 InsertCommand subclass:#InsertBeforeCommand |
|
6 instanceVariableNames:'' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'XQuery-Update Facility' |
|
10 ! |
|
11 |
|
12 |
|
13 !InsertBeforeCommand methodsFor:'checks'! |
|
14 |
|
15 checkSourceSequence:anXQuerySequence |
|
16 |
|
17 | foundNonAttribute | |
|
18 foundNonAttribute := false. |
|
19 anXQuerySequence do: |
|
20 [:seqItem| |
|
21 self |
|
22 assert: ((seqItem type == XQuerySequenceItem typeAttribute and:[foundNonAttribute])) not |
|
23 description:'An attribute found after non-attribute (see section 2.3.1.)'. |
|
24 foundNonAttribute := (seqItem type == XQuerySequenceItem typeAttribute) not] |
|
25 |
|
26 "Modified: / 21-11-2007 / 11:23:52 / janfrog" |
|
27 ! |
|
28 |
|
29 checkTargetSequence: anXQuerySequence |
|
30 |
|
31 self |
|
32 assert: (anXQuerySequence containsSingleElement and:[anXQuerySequence first item hasParent ]) |
|
33 description: 'target must be a single element or document node with parent (see section 2.3.1.)'. |
|
34 |
|
35 "Modified: / 21-11-2007 / 11:24:16 / janfrog" |
|
36 ! ! |
|
37 |
|
38 !InsertBeforeCommand methodsFor:'executing'! |
|
39 |
|
40 execute |
|
41 "Superclass says that I am responsible to implement this method" |
|
42 |
|
43 self sourceSequence |
|
44 do:[:node|self insert: node before: self targetSequence first] |
|
45 |
|
46 "Created: / 21-11-2007 / 11:22:58 / janfrog" |
|
47 ! ! |
|
48 |
|
49 !InsertBeforeCommand methodsFor:'inserting'! |
|
50 |
|
51 insert:sourceNode before:targetNode |
|
52 |
|
53 |importedSourceNodeId| |
|
54 importedSourceNodeId := targetNode documentAdaptor |
|
55 importForeingNode: sourceNode item nodeId |
|
56 adaptor: sourceNode documentAdaptor. |
|
57 |
|
58 (sourceNode type == XQuerySequenceItem typeAttribute) ifFalse:[ |
|
59 targetNode documentAdaptor updInsert:importedSourceNodeId before:targetNode item nodeId |
|
60 ] ifTrue:[ |
|
61 targetNode documentAdaptor updInsertAttribute: importedSourceNodeId into: targetNode item xpathParent first nodeId |
|
62 ] |
|
63 |
|
64 "Created: / 21-11-2007 / 11:27:30 / janfrog" |
|
65 "Modified: / 21-11-2007 / 14:04:18 / janfrog" |
|
66 ! ! |
|
67 |
|
68 !InsertBeforeCommand class methodsFor:'documentation'! |
|
69 |
|
70 version |
|
71 ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xpath/XQuery__InsertBeforeCommand.st,v 1.1 2007-11-22 21:57:56 vranyj1 Exp $' |
|
72 ! ! |