W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2009

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

From: Costello, Roger L. <costello@mitre.org>
Date: Tue, 30 Jun 2009 09:01:23 -0400
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <9E51F88D5247B648908850C35A3BBB500400458C34@IMCMBX3.MITRE.ORG>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:12 GMT