[xsl] XML-Schema (W3C) mailing list?

Subject: [xsl] XML-Schema (W3C) mailing list?
From: Dietrich Bollmann <diresu@xxxxxx>
Date: Fri, 24 Dec 2010 14:17:31 +0900
Hi, 

Is there a mailing list for asking questions concerning the usage of
XML-Schemata (W3C) ?

Thanks, 

Dietrich


PS: For any case, I append the question I would like to ask:

---
Subject:  Is there a way to control child element selection depending on
some parent attribute value?

Hi,

I was asked to implement an XML-Schema
for a sequence made from 

  <list type="a"></list>
  <list type="b"></list>

in any order, for example

  <sequence>
    <list type="a"></list>
    <list type="b"></list>
    <list type="b"></list>
    <list type="a"></list>
    <list type="b"></list>
    ...
  </sequence>

each list looking like the following:

  <list type="a">
    <item type="a"></item>
    <item type="a"></item>
    <item type="a"></item>
    ...
  </list>

or 

  <list type="b">
    <item type="b"></item>
    <item type="b"></item>
    <item type="b"></item>
    ...
  </list>

I suppose a better way to implement this would be by rather using
elements like:

  <aList></aList>
  <bList></bList>

together with

  <aList>
    <item type="a"></item>
    <item type="a"></item>
    <item type="a"></item>
    ...
  </aList>

and

  <bList>
    <item type="b"></item>
    <item type="b"></item>
    <item type="b"></item>
    ...
  </bList>

or even

  <aList>
    <aItem></aItem>
    <aItem></aItem>
    <aItem></aItem>
    ...
  </aList>

and

  <bList>
    <bItem></bItem>
    <bItem></bItem>
    <bItem></bItem>
    ...
  </bList>

But unfortunately I don't control the source XML files...

The latter is easy to implement:

    <xs:element name="sequence">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="aList" type="aItemList"/>
          <xs:element name="bList" type="bItemList"/>
        </xs:choice>
      </xs:complexType>
    </xs:element>

but when trying to implement the original proposal with something like:

    <xs:element name="sequence">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="list">
            <xs:complexType>
              <xs:attribute name="type" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="a"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
          <xs:element name="list">
            <xs:complexType>
              <xs:attribute name="type" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="b"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>

--- both alternatives are using the same element name "list" and only
differ concerning the allowed values of attribute "type": "a" in the
first case, "b" in the latter one --- the schema parser always takes the
first alternative and complaints about the value of the "type" attribute
when not corresponding to the one specified in the first alternative...

When on the other side allowing both values --- "a" as well as "b" ---
for the "type" attribute of the "list" element

    <xs:element name="foo">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="list" maxOccurs="unbounded">
            <xs:complexType>
              <xs:attribute name="type" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="a"/>
                    <xs:enumeration value="b"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>

there seems to be no way to control the "type" value of the "item"
elements inside the "list" in order to make them match the one of the
"list" parent element.  The result is, that the whole approach to
control the elements via the "type" attribute doesn't work at all...

I think this is an implementation decision, as the implementation of a
parser with some king of backtracking or looking forward mechanism would
be much less efficient than one which is based on the supposition, that
all alternative inside of <xs:choice/> have different names and solely
decides based on this criteria.

Still, as I don't control the source documents, I wonder, if there is
some way to implement this kind of restriction using XML Schema...

Thanks for the help,

Dietrich

Current Thread