当我的序列化资源在泽西,我想要使用的名字空间,在某些情况下。

是否有任何方法来自空间的前缀在新泽西?

默认:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns:ns2="http://www.w3.org/2005/Atom">
   <price>123</price>
   <ns2:link rel="duh" href="/abc/123"/>
   <ns2:link rel="abc" href="/def/234"/>
</order>

我想要的东西,如:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns:atom="http://www.w3.org/2005/Atom">
   <price>123</price>
   <atom:link rel="duh" href="/abc/123"/>
   <atom:link rel="abc" href="/def/234"/>
</order>

谢谢, 卢卡斯

有帮助吗?

解决方案

如果你使用 修订的执行可以控制你的前缀使用@xml schema包级别的注释:

@javax.xml.bind.annotation.XmlSchema(  
    xmlns = {  
          @javax.xml.bind.annotation.XmlNs(prefix = "atom", namespaceURI = "http://www.w3.org/2005/Atom")  
            })  
    package org.example.domain;  

使用月修订,你需要有个文件命名的修订。性在与模型的课程有以下条目:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

例的使用月与泽西州参见:

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top