Java 在JAXB中从XML中删除前缀

Java 在JAXB中从XML中删除前缀,java,xml,xsd,jaxb,xml-namespaces,Java,Xml,Xsd,Jaxb,Xml Namespaces,我试图生成一个带有JAXB注释的XML文件 因此,我将从XSD生成JAXB类&package-info.java 让我们走吧: 1-Package-info.java // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 // See <a href="http://java.

我试图生成一个带有JAXB注释的XML文件

因此,我将从XSD生成JAXB类&package-info.java

让我们走吧:

1-Package-info.java

 //
    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 
    // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
    // Any modifications to this file will be lost upon recompilation of the source schema. 
    // Generated on: 2017.01.05 at 01:51:40 PM CET  
    //

    @XmlSchema(
    xmlns = {
            @XmlNs(namespaceURI = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",             prefix = "cac"),
            @XmlNs(namespaceURI = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",                 prefix = "cbc"),
            @XmlNs(namespaceURI = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",                               prefix = "") //this must be empty prefix
    },

    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

    package com.audaxis.compiere.osg.ei.ubl2;
    import javax.xml.bind.annotation.XmlNs;
    import javax.xml.bind.annotation.XmlSchema;
3-结果生成的XML:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Invoice 
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" 
    xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"  
    xmlns:ns11="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" 
    xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 UBL-Invoice-2.1.xsd">
    <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    <-- XML tags -->
    <END XML>

2.1
4-如您所见,第三个名称空间是使用前缀=
ns11
创建的,这将在下一步为我带来问题


问:我如何让它生成不带任何前缀的XML

我以前遇到过这种情况,尽管它最终对我来说并不重要。这会给您带来什么问题?我将XML发送到服务web,使用ns11,服务无法检查XML,没有ns11,它可以检查,所以我必须检查
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Invoice 
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" 
    xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"  
    xmlns:ns11="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" 
    xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 UBL-Invoice-2.1.xsd">
    <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    <-- XML tags -->
    <END XML>