Cannot resolve the name to a(n) 'element declaration' component

19.2k views Asked by At

while compiling maven-jaxb2-plugin I get below error

[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>

Here is 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>

If I use type instead of ref as suggested under Heterogeneous Namespace Design http://www.xfront.com/ZeroOneOrManyNamespaces.html

I get below error

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

There are 1 answers

0
Kachna On BEST ANSWER

CustomerApplicationDetail is a complexType not an element, therefore you have to use type and name. in A.xsd, try this modification:

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