2

Using JAXB, when there is two namespace in the object, I added package-info.java in the pakage, it remove one namespace prefix, like this Jaxb generated xml - problem with root element prefix

My objects like this:

@XmlRootElement(name="Message",namespace="http://404story.com/Order")
public class Root {
    private String id;

    private Codes codes;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

@XmlRootElement(name="Codes")
public class Codes {
    @XmlElement(name = "Code", namespace = "http://404story.com/Code")
    protected List<String> Code;
....
}

package-info.java:

@XmlSchema(namespace = "http://404story.com/Order", elementFormDefault = XmlNsForm.QUALIFIED)
package com.xxxx;

import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

But when there is two namespaces, it turns to be like this: <Message xmlns:ns2="http://404story.com/Code" xmlns="http://404story.com/Order">

and some part will use <ns2:Code>xxx</ns2:Code>. Could you tell me how to remove the ns2 prefix? And put the namespace like:

<Message xmlns="http://404story.com/Order">
  <Codes>
    <Code xmlns="http://404story.com/Code">xxxx</Code>
    <Code xmlns="http://404story.com/Code">xxxx</Code>
  </Codes>
</Message>
Community
  • 1
  • 1
navins
  • 3,429
  • 2
  • 28
  • 29

0 Answers0