简体   繁体   中英

SAXParseException creating an Enum in XSD

I'm having trouble constructing my first XSD file. I'm trying to generate Java POJO's bases on my XSD with jaxb2-maven-plugin .

To start, I've followed the example that I've seen this tutorial

This is my xsd file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <xs:element name = "Tshirt">
        <xs:complexType>
            <xs:sequence>
                <xs:element name = "Color" type = "clothesColorType" />
                <xs:element name = "Size" type = "clothesSizeType" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="clothesSizeType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="S" />
            <xs:enumeration value="M" />
            <xs:enumeration value="L" />
            <xs:enumeration value="XL" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="clothesColorType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Black" />
            <xs:enumeration value="White" />
            <xs:enumeration value="Green" />
            <xs:enumeration value="Blue" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

When my plugin try to parse the file, I get the error

org.xml.sax.SAXParseException; systemId: file:/ruta/src/main/resources/wsdl-definition/Assurance.xsd; lineNumber: 47; columnNumber: 72; src-resolve: No se puede resolver el nombre 'clothesColorType' para un componente 'type definition'.

I have been googling for hours but I have not found the response. Any Ideas?

Thank you in advance.

The schema is valid (Saxon accepts it, so it must be...)

The problem is therefore either with your schema processor, or with the way you are invoking it.

I note that your schema does not have 47 lines, therefore I suspect the file you are actually using differs from the one shown.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM