JAXB - 如何添加xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance

Anu*_*rag 6 java jaxb

我正在使用JAXB从结果集创建XML文件.

我在xjc utiliy的帮助下使用xsd创建了java//类文件.现在我正在尝试使用Marshaller创建xml文件.在XML文件中,我没有看到xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"带有根标记的属性.

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"));
}
Run Code Online (Sandbox Code Playgroud)

代码输出:这不包含XMLSchema值 -

<?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>
Run Code Online (Sandbox Code Playgroud)

请帮助我如何在根标记中添加模式实例值.