union is not a union, it's a sequence

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