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

Permit (greedy) conflicting wildcards

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Thu, 15 Mar 2007 14:22:37 -0000
Message-ID: <001401c76712$0be07480$5900a8c0@Codalogic>
To: <xmlschema-dev@w3.org>
Permit (greedy) conflicting wildcards

Just reading David Orchard's document "Guide to Versioning XML Languages
using XML Schema 1.1"
(http://www.w3.org/TR/2006/WD-xmlschema-guide2versioning-20060928/).

It says that under the current interpretation of XSD 1.1 the following 
(slightly simplified from David's document) is illegal due to the 
minOccurs="0" of middle name allowing the two adjacent wildcards to 
conflict:

    <xs:sequence>
      <xs:element name="given" type="xs:string"/>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="middle" type="xs:string" minOccurs="0"/>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="family" type="xs:string"/>
    </xs:sequence>

It then says that new wording in XSD1.1 has been added to make the following
legal:

    <xs:sequence>
      <xs:element name="given" type="xs:string"/>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
      <xs:sequence minOccurs="0">
          <xs:element name="middle" type="xs:string" />
          <xs:any namespace="##any" processContents="lax"
                minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:element name="family" type="xs:string"/>
    </xs:sequence>

Replacing the xs:anys with xs:element declarations, UPAC wise I don't
think the following would be legal:

    <xs:sequence>
      <xs:element name="given" type="xs:string"/>
      <xs:element name="any" minOccurs="0" maxOccurs="unbounded"/>
      <xs:sequence minOccurs="0">
          <xs:element name="middle" type="xs:string" />
          <xs:element name="any" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:element name="family" type="xs:string"/>
    </xs:sequence>

So I don't see why the second example should be considered anymore
intrinsically legitimate than the first example.

As the second example seems a bit of a fudge, and is non-intuitive and
messy, I propose that the rules be changed to make the first example legal.
Basically a wild card should be allowed to be greedy and gobble up anything
until it encounters something that does match the wild card spec, or is an
immediately accessible element name on the path following the wildcard.

I would even say, if someone wants to do:

    <xs:sequence>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
      <xs:any namespace="##any" processContents="lax"
              minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>

they should be allowed to do it and it wouldn't be an error.  Although
helpful tools might care to issue a warning that they're wasting their time!

Cheers,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============================================
Received on Thursday, 15 March 2007 14:57:09 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.