okonik
okonik

Reputation: 127

XML Schema validator error on attribute definition

I get an error on validation:

Error - Line 14, 36: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 36; s4s-elt-must-match.1: The content of 'simpleType' must match (annotation?, (restriction | list | union)). A problem was found starting at: attribute.

How to resolve it?

My XML fragment

<CHANEL_NAME lang="RUS/MD">N4</CHANEL_NAME>

And XSD:

<xs:element name="CHANEL_NAME">
    <xs:simpleType>
         <xs:restriction base="xs:string">
            <xs:length value="40"/>
        </xs:restriction>
        <xs:attribute name="lang">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="MD"/>
                    <xs:enumeration value="RUS"/>
                    <xs:enumeration value="RUS/MD"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:simpleType>
</xs:element>

So I need in attribute 'lang' only determined values like 'MD', 'RUS' or 'RUS/MD'. I read examples and I guess it's OK.

Or is enumeration only for elements and not for attributes?

Upvotes: 0

Views: 802

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

An element with a simple type can't have attributes. You need a "complex type with simple content", which is defined using an xs:complexType element with an xs:simpleContent child.

Upvotes: 2

Related Questions