Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?

前端 未结 4 528
暖寄归人
暖寄归人 2020-11-30 06:45

For example, I\'ve got a simple schema which imports another schema. The second schema (urn:just:attributes, just-attributes.xsd) just defines an attribute group.



        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 07:01

    I had the same question. In package-info.java (if you don't have it, you can just manually create it) add the xmlns part:

    @javax.xml.bind.annotation.XmlSchema(xmlns = {
            @javax.xml.bind.annotation.XmlNs(namespaceURI = "urn:just:attributes", prefix = "thirdpartyns") }, 
            elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
    

提交回复
热议问题