编译maven-jaxb2-plugin时我得到以下错误
[INFO] --- maven-jaxb2-plugin:0.8.3:generate (default) @ customer-project ---
[ERROR] Error while parsing schema(s).Location [ file:....Customer.xsd{12,97}].
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'ttadcustomer:CustomerApplicationDetail' to a(n) 'element declaration' component.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(
A.xsd
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.cohbe.org/CustomerRequest"
xmlns:ttadcustomer="http://www.cohbe.org/customer"
targetNamespace="http://www.cohbe.org/CustomerRequest"
elementFormDefault="qualified">
<xsd:import schemaLocation="TTAdDETAILS.xsd"
namespace="http://www.cohbe.org/customer"/>
<xsd:element name="CustomerNewRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="ttadcustomer:CustomerApplicationDetail" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
...
</xsd:schema>
这是TTAdDETAILS.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema version="2.15"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.cohbe.org/customer"
targetNamespace="http://www.cohbe.org/customer"
xmlns:countries="http://www.cohbe.org/Counties"
elementFormDefault="qualified">
<xsd:complexType name="CustomerApplicationDetail">
.....
</xsd:schema>
如果我按照异构命名空间设计http://www.xfront.com/ZeroOneOrManyNamespaces.html
中的建议使用类型而不是 ref我得到以下错误
One of 'ref' or 'name' must be present in a local element declaration.
答案 0 :(得分:0)
CustomerApplicationDetail是complexType
而不是element
,因此您必须使用type
和name
。
在 A.xsd 中,尝试以下修改:
<xsd:element name = 'the_name_of_the_element' type = "ttadcustomer:CustomerApplicationDetail" minOccurs="0"/>