开发者

XMLStreamWriter.writeStartElement(prefix,localName,namespaceURI): no binding of prefix to namespace

开发者 https://www.devze.com 2023-03-21 11:33 出处:网络
XMLStreamWriter.writeStartElement(prefix,localName,namespaceURI) (doc link) The namespaceURI parameter is not null, but it failed 开发者_运维问答to bind the prefix to the namespaceURI:

XMLStreamWriter.writeStartElement(prefix,localName,namespaceURI) (doc link)

The namespaceURI parameter is not null, but it failed 开发者_运维问答to bind the prefix to the namespaceURI:

writeStartElement("manifest","manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")

The result file:

<manifest:manifest>

But it should be:

<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">


Set javax.xml.stream.isRepairingNamespaces property to true on the XMLOutputFactory used to construct your stream writer. By default it is turned off.

Accoding to the javadocs for writeStartElement() in XMLStreamWriter:

Throws: XMLStreamException - if the namespace URI has not been bound to a prefix and javax.xml.stream.isRepairingNamespaces has not been set to true

(for some reason the official javadocs don't show the detail text for the exception but my local downloaded ones do)

Either that or you need to explicitly call setPrefix() to register the namespaces first.


I believe you need to setPrefix before writeStartElement. I don't think you'll need sRepairingNamespaces - but I'm not sure.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号