Hi,
I am using JAXB2 marshaller to create an xml file based on the generated classes from the xml schema. I got two questions regarding the namespace:
1. In the root element "ROOT", I need to add attributes xsi:schemaLoaction, xmlns, and xmlns:xsi as below
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT jobname="job"
xsi:schemaLocation="...."
xmlns="........"
xmlns:xsi="..............">....
</ROOT>
But from the generated class ROOT, I am not able to find the setSchemaLocation() or SetXmlns(), How do I set these values to ROOT element?
2. There is another element class that has setCity() method, and this method takes JAXBElement<
String> as argument. I created the JAXBElement<String> as below:
JAXBElement<String> city = new JAXBElement<String>(new QName("city"), String.class, null, "New York"); //cannot get rid of namespace
address.setCity(city);
And the result xml is
<city xmlns:ns2="http://www.mycom.com/XMLSchema/myxsd" xmlns="">New York</city>
I need <city>New York</city>, and how can I get rid of the namespace?
Thanks very much!