mercredi 11 mars 2015

How to include version attribute in output when marshalling



Below is the valid xml .



<Input xsi:noNamespaceSchemaLocation="some.xsd"
version="V16.2"
xmlns:xsi="http://ift.tt/ra1lAU">
<SITE>com</SITE>
<LANGUAGE>SV</LANGUAGE>
</Input>


The XML which I got from XSD to JAXB then XML using Marshallar is:



<Input xsi:noNamespaceSchemaLocation="some.xsd"
xmlns:xsi="http://ift.tt/ra1lAU">
<SITE>com</SITE>
<LANGUAGE>SV</LANGUAGE>
</Input>


SO the problem is that version="V16.2" is missing in the second generated XML, so the consuming code throws an error.


My Marshaller property



Marshaller marshaller= jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "some.xsd");


Can anyone help me figure out how to include a version attribute?




Aucun commentaire:

Enregistrer un commentaire