gpt4 book ai didi

java - XMLStreamWriter.writeStartElement(前缀,本地名称,命名空间URI): no binding of prefix to namespace

转载 作者:太空宇宙 更新时间:2023-11-04 08:34:22 25 4
gpt4 key购买 nike

XMLStreamWriter.writeStartElement(前缀,localName,namespaceURI) ( doc link )

namespaceURI参数不为空,但未能将前缀绑定(bind)到namespaceURI:

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

结果文件:

<manifest:manifest>

但应该是:

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

最佳答案

XMLOutputFactory 上的 javax.xml.stream.isRepairingNamespaces 属性设置为 true用于构建您的流编写器。默认情况下它是关闭的。

根据 XMLStreamWriter 中 writeStartElement() 的 javadoc:

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

(由于某种原因,官方 javadoc 没有显示异常的详细文本,但我本地下载的却显示了)

要么您需要显式调用 setPrefix() 来首先注册命名空间。

关于java - XMLStreamWriter.writeStartElement(前缀,本地名称,命名空间URI): no binding of prefix to namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6728324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com