[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.