[XML Schema 1.1] Conflicting <assert> elements ... who wins?

Hi Folks,

Suppose one <assert> element says "The value of <Publisher> must be a string no longer than 140 characters." 

Another <assert> element says "The value of <Publisher> must be a string no longer than 70 characters."

Which <assert> element wins?

Example: I have an <assert> element on the root element (<BarnesAndNoble>) which says "The value of each <Publisher> element must be a string no longer than 140 characters." I have another <assert> element directly on the <Publisher> element which says: "The value of <Publisher> must be a string no longer than 70 characters." Is <Publisher> constrained to a length of 140 characters or 70 characters?

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">

    <xs:element name="Publisher">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:assert test="not(string-length(.) gt 70)" />
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="Book">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Title" type="xs:string"/>
                <xs:element name="Author" type="xs:string"/>
                <xs:element name="Date" type="xs:gYear"/>
                <xs:element name="ISBN" type="xs:string"/>
                <xs:element ref="Publisher" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="BarnesAndNoble">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Book" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:assert test="not(Book[string-length(Publisher) gt 140])" />
        </xs:complexType>
    </xs:element>

</xs:schema>

/Roger

Received on Tuesday, 30 June 2009 13:02:03 UTC