【发布时间】:2012-05-07 23:14:12
【问题描述】:
我正在尝试创建一个我想要作为原子前缀的 xml 元素。 我知道我不能这样做:
@XmlElement(prefix="atom")
然后创建
<XmlAttribute>
<atom:link ...>
</XmlAttribute>
有没有办法做到这一点?
【问题讨论】:
标签: java annotations jaxb
我正在尝试创建一个我想要作为原子前缀的 xml 元素。 我知道我不能这样做:
@XmlElement(prefix="atom")
然后创建
<XmlAttribute>
<atom:link ...>
</XmlAttribute>
有没有办法做到这一点?
【问题讨论】:
标签: java annotations jaxb
是的,你只需要定义这个前缀对应的命名空间:
@XmlElement(name="link", namespace="..")
这只会将与 atom 前缀对应的命名空间添加到您的 link 元素中。如果您的问题是关于专门将 atom 作为此命名空间的前缀,请查看以下问题:Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?
【讨论】: