W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2012

union is not a union, it's a sequence

From: Costello, Roger L. <costello@mitre.org>
Date: Thu, 18 Oct 2012 12:44:42 +0000
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <B5FEE00B53CF054AA8439027E8FE17751E680614@IMCMBX04.MITRE.ORG>
Hi Folks,

Proposition:
      A union of member types does not produce 
      a union, it produces a sequence of member 
      types.

Proof:    
    <xs:simpleType name="white-space-characters"> 
        <xs:annotation>
            <xs:documentation>
                The space (SP, ASCII value 32) and horizontal tab (HTAB,
                ASCII value 9) characters are known as the white space
                characters, WSP.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[&#9;&#32;]*" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="printable-characters"> 
        <xs:annotation>
            <xs:documentation>
                The printable US-ASCII characters are the characters that 
                have values between 33 and 126, inclusive.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[&#33;-&#126;]*" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="header-field-body-characters">
        <xs:annotation>
            <xs:documentation>
                A field body may be composed of printable US-ASCII characters
                as well as the WSP.
            </xs:documentation>
        </xs:annotation>
        <xs:union memberTypes="printable-characters white-space-characters" />
    </xs:simpleType>

    <xs:element name="header-field-body" type="header-field-body-characters" />

*Valid* instance document:

    <header-field-body>HelloWorld</header-field-body>
  
*Valid* instance document:

    <header-field-body>  </header-field-body>

*Invalid* instance document:

    <header-field-body>Hello  World</header-field-body>  

Therefore the union of printable-characters and white-space-characters does not yield a union of their value spaces; rather, it merely provides a sequence of two types.

Ugh.

So, how do I truly union printable-characters and white-space-characters?

Of course, I could simply copy the regex pattern from printable-characters and white-space-characters and paste:

    <xs:simpleType name="header-field-body-characters"> 
        <xs:annotation>
            <xs:documentation>
                A field body may be composed of printable US-ASCII characters
                as well as the WSP.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[&#9;&#32;&#33;-&#126;]*" />
        </xs:restriction>
    </xs:simpleType>

But that is awful as it is totally disconnected from printable-characters and white-space-characters.

Any suggestions?

/Roger
Received on Thursday, 18 October 2012 12:45:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:02 UTC