author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 25 Jan 2016 16:35:43 +0000 | |
changeset 298 | 9696f76605bd |
parent 296 | ea3dbc023c80 |
child 304 | b3b094899206 |
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 |
XMLWriter subclass:#IndentingXMLWriter |
|
6 |
instanceVariableNames:'indentLevel' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'XML Suite-XML Writer' |
|
10 |
! |
|
11 |
||
12 |
||
13 |
!IndentingXMLWriter class methodsFor:'instance creation'! |
|
14 |
||
15 |
new |
|
16 |
^ self basicNew initialize. |
|
17 |
||
18 |
"Created: / 23-12-2005 / 21:03:15 / janfrog" |
|
19 |
! ! |
|
20 |
||
21 |
!IndentingXMLWriter methodsFor:'SAX2 events'! |
|
22 |
||
23 |
characters:aString |
|
24 |
self nextPutIndentedString:aString |
|
25 |
||
26 |
"Created: / 27-11-2005 / 11:52:48 / janfrog" |
|
27 |
! |
|
28 |
||
29 |
endElement:localName namespace:namespace prefix:prefix |
|
30 |
||
31 |
indentLevel := indentLevel - 1. |
|
32 |
self nextPutIndent. |
|
33 |
super endElement:localName namespace:namespace prefix:prefix. |
|
34 |
self cr. |
|
35 |
||
36 |
"Created: / 27-11-2005 / 11:47:05 / janfrog" |
|
37 |
! |
|
38 |
||
39 |
nextPutIndentedString:aString |
|
40 |
aString asStringCollection do:[:line | |
|
41 |
self |
|
42 |
nextPutIndent; |
|
43 |
nextPutString:line; |
|
44 |
cr. |
|
45 |
] |
|
46 |
||
47 |
"Created: / 27-11-2005 / 11:56:50 / janfrog" |
|
48 |
"Modified: / 28-11-2005 / 16:35:58 / janfrog" |
|
49 |
! |
|
50 |
||
51 |
processingInstruction:target data:data |
|
52 |
||
53 |
self nextPutIndent. |
|
54 |
super processingInstruction:target data:data |
|
55 |
||
56 |
"Created: / 27-11-2005 / 11:54:33 / janfrog" |
|
57 |
! |
|
58 |
||
59 |
startDocument |
|
60 |
||
61 |
indentLevel := 0. |
|
62 |
super startDocument. |
|
63 |
self cr. |
|
64 |
||
65 |
"Created: / 27-11-2005 / 11:42:03 / janfrog" |
|
66 |
! |
|
67 |
||
68 |
startElement:localName namespace:namespace prefix:prefix attributes:attributes |
|
69 |
||
70 |
self nextPutIndent. |
|
71 |
super startElement:localName namespace:namespace prefix:prefix attributes:attributes. |
|
72 |
self cr. |
|
73 |
indentLevel := indentLevel + 1. |
|
74 |
||
75 |
"Created: / 27-11-2005 / 11:45:19 / janfrog" |
|
76 |
! ! |
|
77 |
||
78 |
!IndentingXMLWriter methodsFor:'SAX2 interface - extensions'! |
|
79 |
||
80 |
cDataSection:aString |
|
81 |
||
82 |
self nextPutIndent; nextPutAll:'<!![CDATA['; cr. |
|
83 |
indentLevel := indentLevel + 1. |
|
84 |
self nextPutIndentedString: aString. |
|
85 |
indentLevel := indentLevel - 1. |
|
86 |
self nextPutIndent; nextPutAll:']]>'; cr. |
|
87 |
||
88 |
"Created: / 28-12-2005 / 16:18:04 / janfrog" |
|
89 |
! |
|
90 |
||
91 |
comment:aString |
|
92 |
||
93 |
self nextPutIndent; nextPutAll:'<!!--'; cr. |
|
94 |
indentLevel := indentLevel + 1. |
|
95 |
self nextPutIndentedString: aString. |
|
96 |
indentLevel := indentLevel - 1. |
|
97 |
self nextPutIndent; nextPutAll:'-->'; cr. |
|
98 |
||
99 |
"Created: / 27-11-2005 / 11:57:59 / janfrog" |
|
100 |
! ! |
|
101 |
||
102 |
!IndentingXMLWriter methodsFor:'initialization'! |
|
103 |
||
104 |
initialize |
|
105 |
"Invoked when a new instance is created." |
|
106 |
||
107 |
"/ please change as required (and remove this comment) |
|
108 |
||
109 |
"/ super initialize. -- commented since inherited method does nothing |
|
110 |
indentLevel := 0 |
|
111 |
||
112 |
"Created: / 23-12-2005 / 21:03:15 / janfrog" |
|
113 |
! ! |
|
114 |
||
115 |
!IndentingXMLWriter methodsFor:'writing'! |
|
116 |
||
117 |
nextPutIndent |
|
118 |
||
119 |
self next:(indentLevel * 2) put: Character space |
|
120 |
||
121 |
"Created: / 27-11-2005 / 11:44:39 / janfrog" |
|
122 |
! ! |
|
123 |
||
124 |
!IndentingXMLWriter class methodsFor:'documentation'! |
|
125 |
||
126 |
version |
|
127 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/XMLv2__IndentingXMLWriter.st,v 1.4 2005-12-28 16:16:23 vranyj1 Exp $' |
|
174
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
128 |
! |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
129 |
|
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
130 |
version_SVN |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
131 |
^ '$Id$' |
0 | 132 |
! ! |