获取xml名称空间前缀只显示一次

时间:2014-05-08 00:30:58

标签: xml namespaces jaxb

JAXB问题: 当我的package.Info是:

@javax.xml.bind.annotation.
XmlSchema(
        namespace = "myUrl...",
        location = "myUrl ignoreme.xsd",
        xmlns = {
                @XmlNs(namespaceURI = "myUrl/", prefix = "")
        },
        elementFormDefault = XmlNsForm.QUALIFIED

我得到了:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MyRoot xmlns="myURI..." >   
    <other elements....   >
</MyRoot>

当我在package-info中调整行:

@XmlNs(namespaceURI = "myUrl/", prefix = "ns2")

我得到了:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:MyRoot xmlns:ns2="myURI..." >   
    <other elements....   >
</ns2:MyRoot>

但是我只想要ns2如下(不是在每个标签的开头:)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MyRoot xmlns:ns2="myURI..." >   
    <other elements....   >
<MyRoot>

怎么做?

0 个答案:

没有答案