@@ -37,7 +37,7 @@ import kotlin.jvm.JvmOverloads
37
37
public interface XmlWriter : Closeable {
38
38
39
39
/* *
40
- * The current depth into the tree.
40
+ * The current depth into the tree. The initial depth is `0`
41
41
*/
42
42
public val depth: Int
43
43
@@ -73,12 +73,21 @@ public interface XmlWriter : Closeable {
73
73
namespaceAttr(namespacePrefix.toString(), namespaceUri.toString())
74
74
}
75
75
76
+ /* *
77
+ * Write a namespace declaration attribute.
78
+ */
76
79
public fun namespaceAttr (namespacePrefix : String , namespaceUri : String )
77
80
81
+ /* *
82
+ * Write a namespace declaration attribute.
83
+ */
78
84
public fun namespaceAttr (namespace : Namespace ) {
79
85
namespaceAttr(namespace.prefix, namespace.namespaceURI)
80
86
}
81
87
88
+ /* *
89
+ * Close the writer. After invoking this the writer is not writable.
90
+ */
82
91
override fun close ()
83
92
84
93
/* *
@@ -87,11 +96,9 @@ public interface XmlWriter : Closeable {
87
96
public fun flush ()
88
97
89
98
/* *
90
- * Write a start tag.
99
+ * Write a start tag. This increases the current depth.
91
100
* @param namespace The namespace to use for the tag.
92
- *
93
101
* @param localName The local name for the tag.
94
- *
95
102
* @param prefix The prefix to use, or `null` for the namespace to be assigned automatically
96
103
*/
97
104
public fun startTag (namespace : String? , localName : String , prefix : String? )
@@ -114,25 +121,71 @@ public interface XmlWriter : Closeable {
114
121
*/
115
122
public fun cdsect (text : String )
116
123
124
+ /* *
125
+ * Write an entity reference
126
+ * @param text the name of the reference. Must be a valid reference name.
127
+ */
117
128
public fun entityRef (text : String )
118
129
130
+ /* *
131
+ * Write a processing instruction with the given raw content. When using, prefer the version taking two arguments
132
+ */
119
133
public fun processingInstruction (text : String )
120
134
135
+ /* *
136
+ * Write a processing instruction with the given target and data
137
+ * @param target The (CNAME) target of the instruction
138
+ * @param data The data to be used.
139
+ */
121
140
public fun processingInstruction (target : String , data : String ): Unit =
122
141
processingInstruction(" $target $data " )
123
142
143
+ /* *
144
+ * Write ignorable whitespace.
145
+ * @param text This text is expected to be only XML whitespace.
146
+ */
124
147
public fun ignorableWhitespace (text : String )
125
148
149
+ /* *
150
+ * Write an attribute.
151
+ * @param namespace The namespace of the attribute. `null` and `""` will both resolve to the empty namespace.
152
+ * @param name The local name of the attribute (CName, must exclude the prefix).
153
+ * @param prefix The prefix to use. Note that in XML for attributes the prefix is empty/null when the namespace is and vice versa.
154
+ * @param value The value of the attribute
155
+ */
126
156
public fun attribute (namespace : String? , name : String , prefix : String? , value : String )
127
157
158
+ /* *
159
+ * Write a document declaration (DTD).
160
+ * @param The content of the DTD Declaration.
161
+ */
128
162
public fun docdecl (text : String )
129
163
164
+ /* *
165
+ * Start the document. This causes an xml declaration to be generated with the relevant content.
166
+ * @param version The XML version
167
+ * @param encoding The encoding of the document
168
+ * @param standalone A statement that the document is standalone (no externally defined entities...)
169
+ */
130
170
public fun startDocument (version : String? = null, encoding : String? = null, standalone : Boolean? = null)
131
171
172
+ /* *
173
+ * Close the document. This will do checks, and update the state, but there is no actual content in an xml stream
174
+ * that corresponds to it.
175
+ */
132
176
public fun endDocument ()
133
177
178
+ /* *
179
+ * Write a closing tag.
180
+ * @param namespace The namespace for the tag to close
181
+ * @param localName The local name
182
+ * @param prefix The prefix
183
+ */
134
184
public fun endTag (namespace : String? , localName : String , prefix : String? )
135
185
186
+ /* *
187
+ * A namespace context that provides access to known namespaces/prefixes at this point in the writer.
188
+ */
136
189
public val namespaceContext: NamespaceContext
137
190
138
191
/* *
@@ -146,7 +199,13 @@ public interface XmlWriter : Closeable {
146
199
public fun getPrefix (namespaceUri : String? ): String?
147
200
}
148
201
149
-
202
+ /* *
203
+ * Function that collects namespaces not present in the writer
204
+ * @receiver The writer where namespace information is looked up from
205
+ * @param reader The reader from which the namespace information is retrieved
206
+ * @param missingNamespaces Map to which the "missing" namespace is added.
207
+ */
208
+ @Deprecated(" This function should be internal" )
150
209
public fun XmlWriter.addUndeclaredNamespaces (reader : XmlReader , missingNamespaces : MutableMap <String , String >) {
151
210
undeclaredPrefixes(reader, missingNamespaces)
152
211
}
0 commit comments