XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] enforce at least one element and at most N from a set of N elements- XSD how?

> But that's not particularly pretty and doesn't scale very 
> well.  In that case it's often best to define a looser 
> schema, and then impose the constraint at the application 
> level.  An example schema for that might be:
> 
>     <xs:complexType name='..'>
>             <xs:sequence>
>                 <xs:element name='element1' minOccurs='0'../>
>                 <xs:element name='element2' minOccurs='0'.../>
>                 <xs:element name='element3' minOccurs='0'../>
>                 <xs:element name='element4' minOccurs='0'../>
>             </xs:sequence>
>     <xs:complexType>


Or with XML Schema 1.1 you can use assertions (available in Saxon 9.0, just
released). For example the above type definition could become:

     <xs:complexType name='..'>
             <xs:sequence>
                 <xs:element name='element1' minOccurs='0'../>
                 <xs:element name='element2' minOccurs='0'.../>
                 <xs:element name='element3' minOccurs='0'../>
                 <xs:element name='element4' minOccurs='0'../>
             </xs:sequence>
             <xs:assert test="count(*) = 1 to 4"/>
     <xs:complexType>

Michael Kay
http://www.saxonica.com/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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

Copyright 1993-2007 XML.org. This site is hosted by OASIS