[英]JAXB unmarshaling xml without qualified namespace prefixes
I need to marshal object to xml with qualified namespace form ( <prefix:tag-name>
). 我需要使用限定的名称空间形式(
<prefix:tag-name>
)将对象编组到xml。 And it works fine. 而且效果很好。 I have package-info.java file with
@XmlShema(elementFormDefault=XmlNsForm.QUALIFIED)
but xmls I received comes without namespace prefixes ( <tag-name>
). 我有带有
@XmlShema(elementFormDefault=XmlNsForm.QUALIFIED)
package-info.java文件,但是我收到的@XmlShema(elementFormDefault=XmlNsForm.QUALIFIED)
没有命名空间前缀( <tag-name>
)。 Is there any way to use namespace prefixes just for marshaling with Java 8? 有什么方法可以仅使用Java 8封送处理来使用名称空间前缀吗?
You need to specify the prefix with the @XmlNs
annotation inside your @XmlSchema
annotation: 您需要指定与前缀
@XmlNs
您的内部注释@XmlSchema
注释:
@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = @XmlNs(prefix = "prefix",
namespaceURI = "http://mycompany.com/whatever"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.