Skip to content

Commit 930ca45

Browse files
committed
Fix writing events by considering that DomReader exposes prefix declarations as regular attributes.
1 parent c605432 commit 930ca45

File tree

1 file changed

+10
-8
lines changed
  • core/base/src/commonMain/kotlin/nl/adaptivity/xmlutil

1 file changed

+10
-8
lines changed

core/base/src/commonMain/kotlin/nl/adaptivity/xmlutil/XmlWriter.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,17 @@ public fun XmlWriter.writeCurrentEvent(reader: XmlReader, keepDuplicatedNsDecls:
304304
for (i in reader.attributeIndices) {
305305
val attrPrefix = reader.getAttributePrefix(i)
306306
val namespace = if (attrPrefix == "") "" else reader.getAttributeNamespace(i)
307-
val prefix = when (namespace) {
308-
"" -> ""
309-
namespaceContext.getNamespaceURI(attrPrefix) -> attrPrefix
310-
else -> namespaceContext.getPrefix(namespace) ?: attrPrefix
307+
if (namespace != XMLConstants.XMLNS_ATTRIBUTE_NS_URI) {
308+
val prefix = when (namespace) {
309+
"" -> ""
310+
namespaceContext.getNamespaceURI(attrPrefix) -> attrPrefix
311+
else -> namespaceContext.getPrefix(namespace) ?: attrPrefix
312+
}
313+
attribute(
314+
namespace, reader.getAttributeLocalName(i),
315+
prefix, reader.getAttributeValue(i)
316+
)
311317
}
312-
attribute(
313-
namespace, reader.getAttributeLocalName(i),
314-
prefix, reader.getAttributeValue(i)
315-
)
316318
}
317319
}
318320

0 commit comments

Comments
 (0)