Ariod
Ariod

Reputation: 5851

JAXB, setting namespace to all child elements

I have a class such as the following:

@XmlRootElement(name = "a")
public class ClassA {
    @XmlElement(name = "b", namespace = "http://mynamespace.com")
    private ClassB;
}

This would result in the following XML:

<ns2:a>
    <ns2:b>
        <c/>
    </ns2:b>
</ns2:a>

ClassB and all of its attribute classes are in a separate library not written by me. How can I force those child classes to use the namespace that I've given to ClassB? Like this:

<ns2:a>
    <ns2:b>
        <ns2:c/>
    </ns2:b>
</ns2:a>

Upvotes: 2

Views: 2675

Answers (1)

korifey
korifey

Reputation: 3509

Maybe to put XmlSchema annotation into package with class B

Upvotes: 2

Related Questions