author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 25 Jan 2016 16:35:43 +0000 | |
changeset 298 | 9696f76605bd |
parent 296 | ea3dbc023c80 |
permissions | -rw-r--r-- |
3
7909b6680107
Loaded into & commited from 5.3.6
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
1 |
"{ Package: 'stx:goodies/xmlsuite/core' }" |
0 | 2 |
|
3 |
"{ NameSpace: XMLv2 }" |
|
4 |
||
5 |
ContentHandler subclass:#DOM3Builder |
|
6 |
instanceVariableNames:'currentNode document domImplementation autoWrapInDocumentFragment |
|
7 |
documentFactory' |
|
8 |
classVariableNames:'' |
|
9 |
poolDictionaries:'' |
|
10 |
category:'XML Suite-Parser' |
|
11 |
! |
|
12 |
||
13 |
||
14 |
!DOM3Builder class methodsFor:'instance creation'! |
|
15 |
||
16 |
new |
|
17 |
^ self basicNew initialize. |
|
18 |
||
19 |
"Created: / 12-04-2007 / 12:00:39 / janfrog" |
|
20 |
! ! |
|
21 |
||
22 |
!DOM3Builder methodsFor:'SAX2 interface'! |
|
23 |
||
24 |
characters:aString |
|
25 |
||
26 |
|textNode| |
|
27 |
||
28 |
textNode := self documentFactory createTextNode:aString. |
|
29 |
||
30 |
self currentNode |
|
31 |
ifNil:[currentNode := textNode] |
|
32 |
ifNotNil:[self currentNode appendChild:textNode] |
|
33 |
||
34 |
"Created: / 04-08-2005 / 13:34:25 / janfrog" |
|
35 |
"Modified: / 21-11-2007 / 13:49:45 / janfrog" |
|
36 |
! |
|
37 |
||
38 |
endDocument |
|
39 |
| docType | |
|
40 |
||
41 |
self currentNode |
|
42 |
setStandalone: documentLocator getXmlStandalone; |
|
43 |
setInputEncoding: documentLocator getXmlEncoding; |
|
44 |
setXmlVersion: documentLocator getXmlVersion. |
|
45 |
docType := domImplementation createDocumentType: (currentNode documentElement nodeName) publicId: (documentLocator getPublicId) systemId: (documentLocator getSystemId). |
|
46 |
"/currentNode setDocumentType: docType. |
|
47 |
||
48 |
"Created: / 28-12-2005 / 16:30:34 / janfrog" |
|
49 |
"Modified: / 07-04-2007 / 15:08:58 / janfrog" |
|
50 |
! |
|
51 |
||
52 |
endDocumentFragment |
|
53 |
||
54 |
"| docType | |
|
55 |
||
56 |
self currentNode |
|
57 |
setStandalone: documentLocator getXmlStandalone; |
|
58 |
setInputEncoding: documentLocator getXmlEncoding; |
|
59 |
setXmlVersion: documentLocator getXmlVersion. |
|
60 |
docType := domImplementation createDocumentType: (currentNode documentElement nodeName) publicId: (documentLocator getPublicId) systemId: (documentLocator getSystemId). |
|
61 |
" |
|
62 |
"/currentNode setDocumentType: docType. |
|
63 |
||
64 |
"Created: / 10-08-2007 / 09:22:53 / janfrog" |
|
65 |
! |
|
66 |
||
67 |
endElement:localName namespace:namespace prefix:prefix |
|
68 |
||
69 |
currentNode parent ifNotNil: |
|
70 |
[currentNode := currentNode parent] |
|
71 |
||
72 |
"Created: / 04-08-2005 / 13:29:36 / janfrog" |
|
73 |
"Modified: / 14-11-2007 / 14:47:36 / janfrog" |
|
74 |
! |
|
75 |
||
76 |
ignorableWhitespace:aString |
|
77 |
||
78 |
self characters:aString |
|
79 |
||
80 |
"Created: / 04-08-2005 / 13:34:35 / janfrog" |
|
81 |
! |
|
82 |
||
83 |
processingInstruction:target data:data |
|
84 |
||
85 |
self currentNode appendChild: |
|
86 |
(ProcessingInstruction new |
|
87 |
target:target; |
|
88 |
data:data) |
|
89 |
||
90 |
"Created: / 04-08-2005 / 13:32:41 / janfrog" |
|
91 |
"Modified: / 10-12-2006 / 20:37:58 / janfrog" |
|
92 |
! |
|
93 |
||
94 |
startDocument |
|
95 |
||
96 |
currentNode := document := documentFactory := domImplementation createDocument. |
|
97 |
||
98 |
"Created: / 04-08-2005 / 13:24:13 / janfrog" |
|
99 |
"Modified: / 14-11-2007 / 14:46:21 / janfrog" |
|
100 |
! |
|
101 |
||
102 |
startDocumentFragment |
|
103 |
||
104 |
currentNode := document := documentFactory := domImplementation createDocumentFragment. |
|
105 |
||
106 |
"Created: / 10-08-2007 / 09:22:27 / janfrog" |
|
107 |
"Modified: / 14-11-2007 / 14:46:29 / janfrog" |
|
108 |
! |
|
109 |
||
110 |
startElement:localName namespace:namespace prefix:prefix attributes:attributes |
|
111 |
||
112 |
| element nodeName | |
|
113 |
||
114 |
self currentNode. |
|
115 |
nodeName := NodeName new localName:localName; ns:namespace; prefix:prefix. |
|
116 |
element := self documentFactory createElement: localName ns: namespace. |
|
117 |
element prefix: prefix. |
|
118 |
element setAttributes:attributes. |
|
119 |
"/Element named:nodeName attributes:attributes. |
|
120 |
self currentNode ifNotNil: |
|
121 |
[self currentNode appendChild:element]. |
|
122 |
currentNode := element. |
|
123 |
||
124 |
"Created: / 04-08-2005 / 13:29:20 / janfrog" |
|
125 |
"Modified: / 14-11-2007 / 14:47:52 / janfrog" |
|
126 |
! ! |
|
127 |
||
128 |
!DOM3Builder methodsFor:'SAX2 interface - extensions'! |
|
129 |
||
130 |
attribute:localName namespace:namespace prefix:prefix value: value |
|
131 |
||
132 |
currentNode := Attr new |
|
133 |
localName: localName; |
|
134 |
ns: namespace; |
|
135 |
prefix: prefix; |
|
136 |
nodeValue: value |
|
137 |
||
138 |
"Created: / 14-11-2007 / 15:13:33 / janfrog" |
|
139 |
! |
|
140 |
||
141 |
cDataSection: aString |
|
142 |
||
143 |
self currentNode appendChild: |
|
144 |
(CDATASection new data:aString) |
|
145 |
||
146 |
"Created: / 28-12-2005 / 13:51:31 / janfrog" |
|
147 |
"Modified: / 10-12-2006 / 20:38:11 / janfrog" |
|
148 |
! |
|
149 |
||
150 |
comment:aString |
|
151 |
||
152 |
self currentNode appendChild: |
|
153 |
(Comment new data:aString) |
|
154 |
||
155 |
"Created: / 04-08-2005 / 13:33:47 / janfrog" |
|
156 |
"Modified: / 10-12-2006 / 20:38:15 / janfrog" |
|
157 |
! ! |
|
158 |
||
159 |
!DOM3Builder methodsFor:'accessing'! |
|
160 |
||
161 |
autoWrapInDocumentFragment |
|
162 |
^ autoWrapInDocumentFragment |
|
163 |
||
164 |
"Created: / 14-11-2007 / 14:39:45 / janfrog" |
|
165 |
! |
|
166 |
||
167 |
autoWrapInDocumentFragment:aBoolean |
|
168 |
autoWrapInDocumentFragment := aBoolean. |
|
169 |
||
170 |
"Created: / 14-11-2007 / 14:39:45 / janfrog" |
|
171 |
! |
|
172 |
||
173 |
currentNode |
|
174 |
||
175 |
(currentNode isNil and:[autoWrapInDocumentFragment]) ifTrue:[ |
|
176 |
currentNode := self domImplementation createDocumentFragment. |
|
177 |
document := documentFactory := currentNode ownerDocument. |
|
178 |
]. |
|
179 |
^currentNode |
|
180 |
||
181 |
"Created: / 10-12-2006 / 20:36:28 / janfrog" |
|
182 |
"Modified: / 17-11-2007 / 08:37:17 / janfrog" |
|
183 |
! |
|
184 |
||
185 |
document |
|
186 |
||
187 |
^currentNode |
|
188 |
||
189 |
"Created: / 04-08-2005 / 13:35:07 / janfrog" |
|
190 |
! |
|
191 |
||
192 |
documentFactory |
|
193 |
||
194 |
^documentFactory |
|
195 |
||
196 |
"Created: / 14-11-2007 / 14:45:07 / janfrog" |
|
197 |
! |
|
198 |
||
199 |
domImplementation |
|
200 |
^ domImplementation |
|
201 |
||
202 |
"Created: / 07-04-2007 / 14:58:48 / janfrog" |
|
203 |
! |
|
204 |
||
205 |
domImplementation:aDOMImplementation |
|
206 |
domImplementation := aDOMImplementation. |
|
207 |
||
208 |
"Created: / 07-04-2007 / 14:58:48 / janfrog" |
|
209 |
! ! |
|
210 |
||
211 |
!DOM3Builder methodsFor:'initialization'! |
|
212 |
||
213 |
initialize |
|
214 |
||
215 |
||
216 |
domImplementation := DOMImplementationRegistry getDOMImplementation:'+XML 3.0 '. |
|
217 |
autoWrapInDocumentFragment := true. |
|
218 |
documentFactory := self domImplementation createDocumentFragment |
|
219 |
||
220 |
"Created: / 12-04-2007 / 12:00:39 / janfrog" |
|
221 |
"Modified: / 14-11-2007 / 14:45:54 / janfrog" |
|
222 |
! ! |
|
223 |
||
224 |
!DOM3Builder class methodsFor:'documentation'! |
|
225 |
||
226 |
version |
|
227 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/XMLv2__DOM3Builder.st,v 1.11 2007-11-22 22:18:41 vranyj1 Exp $' |
|
174
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
228 |
! |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
229 |
|
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
230 |
version_SVN |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
231 |
^ '$Id$' |
0 | 232 |
! ! |