我正在尝试使用具有以下格式的 JAXB 创建 Companies House XML
<GovtTalkMessage schemaLocation="schema1" xlmns="" xlmns:bs= "" xlmns:gt="">
<Header> .... </Header>
<Body>
<FormSubmission schemaLocation="schema2" xlmns="" xlmns:xx="">
.....
<CompanyIncorporation schemaLocation="schema3" xlmns="" xlmns:yy="">
...
</CompanyIncorporation>
</FormSubmission>
</Body>
</GovtTalkMessage>
除了schemalocations 和 xlmns之外,XML 结构已正确生成,schemalocation 不会为它应该存在的任何元素生成,并且所有 xmlns 都在 <GovtTalkMessage>
类似
<GovtTalkMessage schemaLocation="schema1" xlmns="" xlmns:bs= "" xlmns:gt="" xlmns:xx="" xlmns:yy="">
FormSubmission
并由CompanyCorporation
生成 。@XmlRootElement
_xjc
xmlns 和 schemalocation 值的相关 @XmlSchema 属性已添加到 package-info.java 中,也按照此处@XmlElementDecl
的建议进行了尝试,但对我没有帮助。
CompanyIncorportion package-info.java:
@XmlSchema(namespace = "",
xmlns = {
@XmlNs(namespaceURI = "http://xmlgw.companieshouse.gov.uk", prefix = ""),
@XmlNs(namespaceURI = "http://www.w3.org/2001/XMLSchema-instance" , prefix="xsi")
},
location = "http://xmlgw.companieshouse.gov.uk http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/CompanyIncorporation-v2-6.xsd",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNSET)
package com.xx.ch;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
网关 package-info.java :
@XmlSchema(namespace = "",
xmlns = {
@XmlNs(namespaceURI = "http://www.w3.org/2000/09/xmldsig#", prefix = "dsig"),
@XmlNs(namespaceURI = "http://www.govtalk.gov.uk/schemas/govtalk/core", prefix = "gt"),
@XmlNs(namespaceURI = "http://www.w3.org/2001/XMLSchema-instance" , prefix="xsi")
},
location = "http://www.govtalk.gov.uk/CM/envelope http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch-v2-0.xsd",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.xx.gateway;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
FormSubmission package-info.java:
@XmlSchema(namespace = "",
xmlns = {
@XmlNs(namespaceURI = "http://xmlgw.companieshouse.gov.uk", prefix = "bs"),
@XmlNs(namespaceURI = "http://xmlgw.companieshouse.gov.uk/Header", prefix = ""),
@XmlNs(namespaceURI = "http://www.w3.org/2001/XMLSchema-instance" , prefix="xsi")
},
// location ="http://xmlgw.companieshouse.gov.uk/Header http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/FormSubmission-v2-7.xsd" ,
//@javax.xml.bind.annotation.XmlSchema(namespace = "http://xmlgw.companieshouse.gov.uk/Header",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.xx.formsubmission;
import javax.xml.bind.annotation.XmlNs;
我如何生成它们schemalocations
以及xmlns
网关在哪里需要它们?