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] Conditional xml Schema

[ Lists Home | Date Index | Thread Index ]

Cross field constraints are better off described thru rule based
validation languages like schematron. Use this in conjunction with the
XSD to enable cross field validation on fields.

<pattern name="checkMangoOrApple">
  <rule context="Fruit">
     <assert test="@myAttr='Apple' and elementApple1>If myAttr is
apple, elementApple1 should be present"/>
     <assert test="@myAttr='Mango' and elementMango1>If myAttr is
mango, elementMango1 should be present"/>
  </rule>
</pattern>



On 6/11/06, Joe Schaffner <schaffner.joe@gmail.com> wrote:
> Why don't you define a Mango element and an Apple element, each with
> their own structure? I'll bet there is even a way to define a Fruit
> element, then derive an Apple and a Mango from Fruit. Then you would
> instantiate either type of fruit, Apple or Mango, and get the proper
> structure.
> Joe
> http://modern-greek-verbs.tripod.com/agv/
> PS
> It looks like you are trying to use the attribute to name the element
> type, which would be unnecessary, and it would surprise me if xsd --
> or any schema definition language -- would attribute class semantics
> to the arrtibutes you create arbitrarily. You are trying to place your
> metadata in the data domain.
>
> On 6/11/06, Jirka Kosek <jirka@kosek.cz> wrote:
> > Jagdishwar B wrote:
> >
> > > Is it possible to define the xml schema (xsd) conditionally based on
> > > certain values.
> >
> > No. You have to use RELAX NG or Schematron to express such constraints.
> >
> > --
> > ------------------------------------------------------------------
> >   Jirka Kosek     e-mail: jirka@kosek.cz     http://www.kosek.cz
> > ------------------------------------------------------------------
> >   Profesionální školení a poradenství v oblasti technologií XML.
> >      Podívejte se na náš nově spuštěný web http://DocBook.cz
> >        Podrobný přehled školení http://xmlguru.cz/skoleni/
> > ------------------------------------------------------------------
> >                    Nejbližší termíny školení:
> >        ** DocBook 15.-17.5.2006 ** XSL-FO 12.-13.6.2006 **
> >     ** XSLT 23.-26.10.2006 ** XML schémata 13.-15.11.2006 **
> > ------------------------------------------------------------------
> >   http://xmlguru.cz    Blog mostly about XML for English readers
> > ------------------------------------------------------------------
> >
> >
> >
> >
>


-- 
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!

-Ramkumar Menon
 A typical Macroprocessor




 

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

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