JAXB namespace prefixes missing

后端 未结 3 480
死守一世寂寞
死守一世寂寞 2020-12-05 00:02

I have generated Java classes from XSD, all works fine from a unmarshalling point of view.

However, when I marshall from JAXB classes I get the following:

         


        
3条回答
  •  旧时难觅i
    2020-12-05 00:44

    You can use the @XmlSchema annotation on a package-info class to assign a prefix to the namespace:

    @XmlSchema(
        namespace = "http://poc.cmc.com/ScreenLayout",
        elementFormDefault = XmlNsForm.QUALIFIED,
        xmlns={@XmlNs(prefix="ns0", namespaceURI="http://poc.cmc.com/ScreenLayout")})    
    package your.package;
    
    
    import javax.xml.bind.annotation.*;
    

提交回复
热议问题