OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XML schema cos-nonambig problem

[ Lists Home | Date Index | Thread Index ]

>    <define name="contentiddef">
>      <choice>
>        <interleave>
>          <optional>
>            <element name="major" ns="http://www.polopoly.com/polopoly/
> cm/app/xml">
>              <choice>
>                <text/>
>                <data type="integer"/>
>              </choice>
>            </element>
>          </optional>
>          <element name="externalid" ns="http://www.polopoly.com/
> polopoly/cm/app/xml">
>            <text/>
>          </element>
>        </interleave>
>        <interleave>
>          <element name="major" ns="http://www.polopoly.com/polopoly/
> cm/app/xml">
>            <choice>
>              <text/>
>              <data type="integer"/>
>            </choice>
>          </element>
>          <element name="minor" ns="http://www.polopoly.com/polopoly/
> cm/app/xml">
>            <data type="nonNegativeInteger"/>
>          </element>
>          <optional>
>            <element name="version" ns="http://www.polopoly.com/
> polopoly/cm/app/xml">
>              <data type="integer"/>
>            </element>
>          </optional>
>        </interleave>
>      </choice>
>    </define>

OK, let me try...

In short this is

  (ma? & e) | (ma & mi & v?)

This can also be written deterministically as:

  (e ma?) |
  (ma (e | mi v? | v mi)) |
  (mi (ma v? | v ma)) |
  (v (ma mi | mi ma))

In XSD this becomes:

<xs:complexType name="contentiddef">
  <xs:choice>
    <xs:sequence>
      <xs:element ref="x:externalid"/>
      <xs:element ref="x:major" minOccurs="0"/>
    </xs:sequence>
    <xs:sequence>
      <xs:element ref="x:major"/>
      <xs:choice>
        <xs:element ref="x:externalid"/>
        <xs:sequence>
          <xs:element ref="x:minor"/>
          <xs:element ref="x:version" minOccurs="0"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element ref="x:version"/>
          <xs:element ref="x:minor"/>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
    <xs:sequence>
      <xs:element ref="x:minor"/>
      <xs:choice>
        <xs:sequence>
          <xs:element ref="x:major"/>
          <xs:element ref="x:version" minOccurs="0"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element ref="x:version"/>
          <xs:element ref="x:major"/>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
    <xs:sequence>
      <xs:element ref="x:version"/>
      <xs:choice>
        <xs:sequence>
          <xs:element ref="x:major"/>
          <xs:element ref="x:minor"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element ref="x:minor"/>
          <xs:element ref="x:major"/>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
  </xs:choice>
</xs:complexType>

This is actually just building a FSM from the relax schema. I'm not sure
if this can be done for every relax schema. But at least for those schemas
that do have a FSM, it can be done automatically. So there might be a tool
out there that does this. Does anyone know one?

greetings,

--
Sjoerd Visscher
http://w3future.com/weblog/






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS