Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSchema question

From: George Cristian Bina <george@---------.--->
To: Sandra Martinez <sandra.martinez@----.--->
Date: 8/7/2006 7:49:00 PM
Hi Sandra,

This is not supported by XML Schema. What you can do is to define a more 
relaxed content model (for instance a zero or more choice of all the 
possible elements) and add Schematron embedded rules to check the 
occurrences constraints for each child element.

You can find an example schema below. This allows any number of BBB and 
CCC elements to be interleaved with zero or one EEE elements and with 
one or more DDD elements.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="AAA">
     <xsd:annotation>
       <xsd:appinfo>
         <pattern xmlns="http://www.ascc.net/xml/schematron" 
name="testOccurences">
           <rule context="AAA">
             <assert test="count(DDD)>0">DDD should appear one or more 
times</assert>
             <assert test="count(EEE)&lt;2">EEE should appear at most 
once</assert>
           </rule>
         </pattern>
       </xsd:appinfo>
     </xsd:annotation>
     <xsd:complexType mixed="false">
       <xsd:choice minOccurs="0" maxOccurs="unbounded">
         <xsd:element name="BBB" type="xsd:string"/>
         <xsd:element name="CCC" type="xsd:string"/>
         <xsd:element name="DDD" type="xsd:string"/>
         <xsd:element name="EEE" type="xsd:string"/>
       </xsd:choice>
     </xsd:complexType>
   </xsd:element>
</xsd:schema>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


Sandra Martinez wrote:
> 
> Could someone provide any ideas or work-around on the following issue:
> 
> I am trying to design a Xschema that allows an unordered list of 
> elements where some of the elements are unbounded, have occurrences of 0 
> or 1,  or 1 to unbounded.  Based on the  XSchema constraint that 
> <xsd:all> does not allowed 0..unbounded elements, I decided to used the 
> following work-around which works for an unordered list of unbounded 
> elements but it does not work for the other two cases. The question is: 
> How can I modified this XSxhema to allow an additional  element child 
> <AAA> whose occurrence is 0 or 1 and that could also be placed in any 
> order (unordered) and also allow for an additional elemen <DDD> whose 
> occurance is one to unbounded and that could also be placed in any order 
> (unordered):
> 
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>         <xsd:element name="AAA">
>                 <xsd:complexType mixed="false">
>                                 <xsd:sequence minOccurs="0" 
> maxOccurs="unbounded">
>                                         <xsd:element name="BBB" 
> type="xsd:string" minOccurs="0"/>
>                                         <xsd:element name="CCC" 
> type="xsd:string" minOccurs="0"/>
>                                 </xsd:sequence>
>                 </xsd:complexType>
>         </xsd:element>
> </xsd:schema>
> 
> 
> 
>  valid XML instance 1:
> 
> <AAA>
>         <BBB>222</BBB>
>         <CCC>ZZZ</CCC>
> </AAA>
> 
> valid XML instance 2:
> 
> <AAA>
>         <CCC>ZZZ</CCC>
>         <BBB>222</BBB>
> </AAA>
> 
> valid XML instance 3:
> 
> <AAA>
>         <BBB>222</BBB>
>         <CCC>ZZZ</CCC>
>         <BBB>222</BBB>
> </AAA>
> 
> valid XML instance 4:
> 
> <AAA>
>         <BBB>222</BBB>
> </AAA>
> 
> 
> Thank you in advanced,
> 
> Sandra
> 
> 
> Sandra I. Martinez
> National Institute of Standards and Technology
> 100 Bureau Drive, Stop 8970,
> Gaithersburg, Md. 20899
> 
> (301) 975-3579
> sandra.martinez@n...
> 
> 
> 

From noah_mendelsohn@u... Mon Aug 07 14:36:31 2006
Received: from aji.w3.org ([133.27.228.225])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1GA6DX


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent