[Playlist] Schema files and element order

Sebastian Pipping webmaster at hartwork.org
Sat Feb 17 02:45:44 UTC 2007


I did some math about the "unroll solution".
This is what I got:

Let's say we have an element with
these children types:
 * zero or one <a>
 * zero or one <b>
 * zero or more <c>
 * zero or more <d>


We start from just <a> and <b> and get
this code for all (only two) combinations:

<choice>
  <sequence>
    <element name="a" minOccurs="0" maxOccurs="1">
    <element name="b" minOccurs="0" maxOccurs="1">
  </sequence>
  <sequence>
    <element name="b" minOccurs="0" maxOccurs="1">
    <element name="a" minOccurs="0" maxOccurs="1">
  </sequence>
</choice>


We then mix in <c> and get this code:

<choice>
  <sequence>
    <element name="c" minOccurs="0" maxOccurs="unbounded">
    <element name="a" minOccurs="0" maxOccurs="1">
    <element name="c" minOccurs="0" maxOccurs="unbounded">
    <element name="b" minOccurs="0" maxOccurs="1">
    <element name="c" minOccurs="0" maxOccurs="unbounded">
  </sequence>
  <sequence>
    <element name="c" minOccurs="0" maxOccurs="unbounded">
    <element name="b" minOccurs="0" maxOccurs="1">
    <element name="c" minOccurs="0" maxOccurs="unbounded">
    <element name="a" minOccurs="0" maxOccurs="1">
    <element name="c" minOccurs="0" maxOccurs="unbounded">
  </sequence>
</choice>


Now the second variable-number child <d>:

<choice>
  <sequence>
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
    <element name="a" minOccurs="0" maxOccurs="1">
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
    <element name="b" minOccurs="0" maxOccurs="1">
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
  </sequence>
  <sequence>
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
    <element name="a" minOccurs="0" maxOccurs="1">
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
    <element name="b" minOccurs="0" maxOccurs="1">
    <sequence minOccurs="0" maxOccurs="unbounded">
      <choice>
         <element name="c">
         <element name="d">
      </choice>
    </sequence>
  </sequence>
</choice>


That frame will work for any combination of zero-or-one (zoo)
and zero-or-more (zom) child elements. The number of combinations
is equal to (#zoo)!, the faculty of the number of zero-or-one
child element types. That gets large very fast!

For <track> that would be 8! = 40,320 combinations.
For <playlist> that would be 11! = 39,916,800 combinations!
So if that way really is the only way to teach XSD speaking
XSPF then this should make clear why WXS/XSD is a bad choice
for a XSPF schema.



Sebastian



More information about the Playlist mailing list