1

I need to generate an XML document that starts like:

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance">

As such I have modified the package-info.java to be as followed:

@javax.xml.bind.annotation.XmlSchema( namespace = "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"
                                , xmlns = { @javax.xml.bind.annotation.XmlNs( prefix="xsi"
                                                                            , namespaceURI="http://www.w3.org/2001/XMLSchema-instance")
                                          }
                                , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
                                )
package mypackage;

But the output is:

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02">

I'm not sure where to start looking as everything that everything that I find says to do exactly what I am doing...

UPDATE: I solved this by using MOXy as the JAXB implementation; code was OK, seems to be a problem with the implementation I was using :\

XSen
  • 188
  • 1
  • 2
  • 9

1 Answers1

0

I have the example below and works correctly. Try and if you have any question, Ill try to help.

elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
    @XmlNs(prefix = "xsi", namespaceURI = "http://www.w3.org/2001/XMLSchema-instance")
})

regards

Arsench
  • 179
  • 2
  • 4
  • 17
  • Try adding some description like say __'you have this thing incorrect, it must be that'__ This make a answer more useful even for you when you revisit it in future – mtk May 05 '15 at 11:26