【发布时间】:2013-05-08 10:47:17
【问题描述】:
一段时间以来,我一直无法将命名空间添加到属性。我的要求是创建 xml,它将在子元素而不是根元素上具有命名空间 uri。我正在使用 jaxb 和 eclipselink moxy,jdk7。
<document>
<Date> date </Date>
</Type>type </Type>
<customFields xmlns:pns="http://abc.com/test.xsd">
<id>..</id>
<contact>..</contact>
</customFields>
</document>
Classes are:
@XmlRootElement(name = "document")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"type","date", "customFields"})
public class AssetBean {
@XmlElement(name="Type")
private String type;
@XmlElement(name="Date")
@XmlElement(name = "CustomFields",namespace = "http://api.source.com/xsds/path/to/partner.xsd")
private CustomBean customFields = new CustomBean();
//getters/setters here
}
public class CustomBean {
private String id;
private String contact;
//getter/setter
}
package-info.java
@javax.xml.bind.annotation.XmlSchema (
xmlns = {
@javax.xml.bind.annotation.XmlNs(prefix="pns",
namespaceURI="http://api.source.com/xsds/path/to/partner.xsd")
},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED
)
package com.abc.xyz
我按照这篇文章寻求帮助,但无法得到我正在尝试的内容 http://blog.bdoughan.com/2010/08/jaxb-namespaces.html
谢谢
【问题讨论】:
标签: namespaces jaxb