我在package-info.java中使用了@xmlSchema注解,但是没有效果,有没有遇到相同问题的,求解答
@XmlSchema(
xmlns={@XmlNs(prefix="xs",namespaceURI="http://www.w3.org/2001/XMLSchema"),@XmlNs(prefix="xdb",namespaceURI="http://xmlns.oracle.com/xdb")}
,namespace="urn:Declaration:datamodel:standard:CN:MT3101:1"
,elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED
,attributeFormDefault=javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED
)
package com.company.ferry.cyhl.cy.domain.so.arrfiles;
生成的xml字符串:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:XMLObject xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:ns3="urn:Declaration:datamodel:standard:CN:MT3101:1">
<ns3:tid>1101</ns3:tid>
<ns3:tname>zhangsan</ns3:tname>
<ns3:address>
<ns3:email>22@163.com</ns3:email>
</ns3:address>
</ns3:XMLObject>
很无奈,,,,,根据jdk的API ,, xmlns:ns3部分应该是targetNamespace=的,,但是现在这样,根本就达不到效果
把package-info中的
@XmlSchema(
xmlns={@XmlNs(prefix="xs",namespaceURI="http://www.w3.org/2001/XMLSchema"),@XmlNs(prefix="xdb",namespaceURI="http://xmlns.oracle.com/xdb")}
,namespace="urn:Declaration:datamodel:standard:CN:MT3101:1"
,elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED
,attributeFormDefault=javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED
)
package com.company.ferry.cyhl.cy.domain.so.arrfiles;
改成@XmlSchema(
namespace="urn:Declaration:datamodel:standard:CN:MT3101:1"
,xmlns={@XmlNs(prefix="xsd",namespaceURI="http://www.sdeport.gov.cn/xsd/ArrivalSchema.xsd")
,@XmlNs(prefix="",namespaceURI="urn:Declaration:datamodel:standard:CN:MT3101:1")}
,elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED
)
package com.company.ferry.cyhl.cy.domain.so.arrfiles;
生成的xml内容为
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLObject xmlns="urn:Declaration:datamodel:standard:CN:MT3101:1" xmlns:xsd="http://www.sdeport.gov.cn/xsd/ArrivalSchema.xsd">
<tid>1101</tid>
<tname>zhangsan</tname>
<address>
<email>22@163.com</email>
</address>
</XMLObject>