I am using JAXB to create XML file from a result set.
I have created java/ /class files using the xsd with the help of xjc utiliy. Now I am trying to create the xml file using the Marshaller. In the XML file I do not see the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
attribute with the root tag.
public class JAXBConstructor
{
public void generateXMLDocument(File xmlDocument){
try
{
JAXBContext jaxbContext = JAXBContext.newInstance("com");
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
com.ObjectFactory factory = new com.ObjectFactory();
USERTASKSImpl userTasks =(USERTASKSImpl)(factory.createUSERTASKS());
USERTASKTypeImpl userTaskType = (USERTASKTypeImpl)(factory.createUSERTASKSTypeUSERTASKType());
userTaskType.setName("zmannan");
userTaskType.setCode("G5023920");
java.util.List userTaskList=userTasks.getUSERTASK();
userTaskList.add(userTaskType);
marshaller.marshal(userTasks, new FileOutputStream("User_Task.xml"));
}
Output of the code : This does not contain the XMLSchema value -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<USER_TASKS xmlns="http://schemas.jpmchase.net/Recertification">
<USER_TASK>
<Code>G5023920</Code>
<Name>zmannan</Name>
</USER_TASK>
</USER_TASKS>
Please help how can I add the schema-instance value in the root tag.