2015-06-20 20 views
0

在編譯Maven的JAXB2-插件我得到以下錯誤無法解析的名字命名的(N)'元素聲明組件

[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

的建議,我得到以下錯誤

One of 'ref' or 'name' must be present in a local element declaration. 

回答

0

CustomerApplicationDetail是complexType不是element,因此你必須使用typename。 in A.xsd,嘗試此修改:

<xsd:element name = 'the_name_of_the_element' type = "ttadcustomer:CustomerApplicationDetail" minOccurs="0"/> 
相關問題