Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Conditional Schema Processing

From: Michael Glavassevich <mrglavas@--.---.--->
To: "Zac Harvey" <zachary.harvey@-----.--->
Date: 12/5/2008 7:48:00 AM
XML Schema 1.1 introduces a new feature called type alternatives (aka
conditional type assignment) which allows you to do this. There's an
implementation in the current development stream of Xerces-J; still not=

quite ready for prime time, but should be available in a release soon.

Thanks.

[1] http://www.w3.org/TR/xmlschema11-1/#cTypeAlternative

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@c...
E-mail: mrglavas@a...

zachary.harvey@g... wrote on 12/05/2008 12:11:10 PM:

> This may be bad design, so if it is, then I guess what I'm looking
> for is an elegant alternative solution. However I don't believe the
> following to be a product of poor design, and so the following
> question should apply:
>
> I want a particular element, <widget> to force the user to define a f=
oo
> attribute, which will be an enum type of three potential values: me, =
you
or us
> . For example:
>
> <widget foo="me" />
> <widget foo="you" />
> <widget foo="us" />
>
> Would all be legal <widget> instantiations. And so I have the
> following so far in my XSD:
>
> <xs:element name="widget" minOccurs="1" maxOccurs="unbounded">
>     <xs:complexType>
>         <xs:attribute name="foo" type="xs:string" use="required=
">
>             <xs:simpleType>
>                 <xs:restriction base="xs:string">
>                     <xs:enumeration value="me" />
>                     <xs:enumeration value="you" />
>                     <xs:enumeration value="us" />
>                 </xs:restriction>
>             </xs:simpleType>
>         </xs:attribute>
>
>         <xs:sequence>
>             <!-- No definition yet ... -->
>         </xs:sequence>
>     </xs:complexType>
> </xs:element>
>
> What I am looking for is the ability to define <widget>'s sequence
> based on the value of foo.  If foo="me" I want it to contain, say,
> an <apple> element. Else if it is "you" or "us" I want it to contain
> an <orange> child element.  So for example:
>
> <widget foo="me">
>     <apple>Hello!</apple>
> </widget>
>
> <widget foo="us">
>     <orange>XSD!</orange>
> </widget>
>
> I have been pouring through the tutorials and cannot find a way to
> include this conditional functionality...=


transparent
Print
Mail
Like It
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