小编Fra*_*ran的帖子

@xmlSchema注释与jaxb一起使用

我无法在xml文件中显示在包级别使用@xmlSchema批注配置的所有参数.例如,如果我设置:

@javax.xml.bind.annotation.XmlSchema (               
    xmlns = { 
            @javax.xml.bind.annotation.XmlNs(prefix = "com", 
                     namespaceURI="http://es.indra.transporte.common"),

            @javax.xml.bind.annotation.XmlNs( prefix = "xsi",
                     namespaceURI="http://www.w3.org/2001/XMLSchema-instance"),

            @javax.xml.bind.annotation.XmlNs( prefix = "ns2",
                     namespaceURI="http://es.indra.transporte.configuration"),             
           },    
    location = "http://es.indra.transporte.configuration StationNetwork.xsd",
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED        
)
package es.indra.transporte.central.thalesinterface.common.beans;
Run Code Online (Sandbox Code Playgroud)

我希望看到类似的东西:

<stationNetwork xmlns:ns2="http://es.indra.transporte.configuration"
                xmlns:com="http://es.indra.transporte.common"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://es.indra.transporte.configuration StationNetwork.xsd">
Run Code Online (Sandbox Code Playgroud)

但我得到以下输出:

<stationNetwork xmlns:com="http://es.indra.transporte.common">
Run Code Online (Sandbox Code Playgroud)

我做错了什么?如何获得预期的输出?

xml schema annotations jaxb

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

annotations ×1

jaxb ×1

schema ×1

xml ×1