Re: Help: Is this possible at all with XML schema?

Hi Victoria,

>I need a schema for the following XML:
>(In "Test", all of the elements (name, description,case) are not in any particular order. "name" and "description" appear 0 or 1 time. "case" appears 0 to unbounded times.)
>
><Test>
>  <name>my test</name>
>  <description>need help</description>
>  <case ref="case1"/>
>  <case ref="case2"/>
></Test>
>
><Case id="case1"/>
><Case id="case2"/>
>
>Is this possible at all?
>
No, you can't get exactly this.

>The closest thing that I do know how to model is the following:
>
><Test>
>  <name>my test</name>
>  <description>need help</description>
>  <set_of_cases>
>    <case ref="case1"/>
>    <case ref="case2"/>
>  </set_of_cases>
></Test>
><Case id="case1"/>
><Case id="case2"/>
>
>schema:
>
><xs:complexType name="Test">
>  <xs:all>
>    <xs:element name="name"/>
>    <xs:element name="description"/>
>    <xs:element ref="set_of_cases"/>
>  </xs:all>
></xs:complexType>
>
><xs:element name="set_of_cases">
>  <xs:complexType>
>    <xs:sequence>
>      <xs:element name="case" minOccurs="1"
>maxOccurs="unbounded">
>         <xs:complexType>
>            <xs:attribute name="ref"/>
>          </xs:complexType>
>       </xs:element>
>     </xs:sequence>
>   </xs:complexType>
></xs:element>
>  
>
Yep, that's as close as you can get by using W3C XML Schema alone. 
However, if you have the ability add Schematron rules to your schema 
then you can express exactly this content model. See [1] for more 
information and there is one example that does exactly what you're 
looking for [2].

Cheers,
/Eddie

[1] http://www.topologi.com/public/Schtrn_XSD/Paper.html
[2] 
http://www.topologi.com/public/Schtrn_XSD/Paper.html#2Interleaving_of_elements

>Thank you very much.
>
>victoria
>
>__________________________________________________
>Do you Yahoo!?
>New DSL Internet Access from SBC & Yahoo!
>http://sbc.yahoo.com
>
>  
>

Received on Thursday, 26 September 2002 00:02:27 UTC