Home > Back-end >  JAXB :Need Namespace Prefix to all the elements inside others
JAXB :Need Namespace Prefix to all the elements inside others

Time:11-22

jaxb groups all tags in one, I need each tag to have its own namespace.

have:

<Request env="DEV" xmlns="http://test1" "xmlns:ns2="urn://test2">
            <ApplicationData>
                <ns2:Application>
                     <Square>test</Square>
                </ns2:Application>
            </ApplicationData>
</Request>

need:

<Request env="DEV" xmlns="http://test1">
            <ApplicationData>
                <Application xmlns ="urn://test2">
                     <Square>test</Square>
                </Application>
            </ApplicationData>
</Request>

adding namespace into @XmlElement didn't help

@XmlElement(
        name = "Application",
        required = true,
        namespace = "urn://test2")

package-info:

@javax.xml.bind.annotation.XmlSchema(
        namespace = "http://test1",
        elementFormDefault = XmlNsForm.QUALIFIED,
        xmlns = {
            @XmlNs(prefix = "", namespaceURI = "http://test1")
        })

CodePudding user response:

this is not possible with standard jaxbe. JAXB Namespace on each xml tag

CodePudding user response:

I had a similar problem and came to the conclusion that it is not solved

  • Related