[
Lists Home |
Date Index |
Thread Index
]
Then wouldn't the following work:
<xs:complexType name="Fruit">
<xs:choice>
<xs:group ref="apple"/>
<xs:group ref="orange"/>
</xs:choice>
</xs:complexType>
<xs:group name="apple">
<xs:element name="Name" type="xs:string" fixed="Apple"/>
<xs:element name="Abbrev" type="xs:token" fixed="APL"/>
</xs:group>
<xs:group name="orange">
<xs:element name="Name" type="xs:string" fixed="Orange"/>
<xs:element name="Abbrev" type="xs:token" fixed="ORG"/>
</xs:group>
-BKN
----- Original Message -----
From: "Chiusano Joseph" <chiusano_joseph@bah.com>
To: "Robert Koberg" <rob@koberg.com>
Cc: "Linda Grimaldi" <grimlinda@earthlink.net>; <xml-dev@lists.xml.org>
Sent: Tuesday, May 04, 2004 4:30 PM
Subject: Re: [xml-dev] Schema validation question
> Not quite, as the approach you propose below still uses data as metadata
> (i.e. "APL" should be a data value, according to the original
> requirement).
>
> The original requirement was: if the data associated with the node
> <Fruit><Name> is "Apple", then the value of the sibling node
> <Fruit><Abbrev> must be "APL". This means that the following XML
> document fragment is considered valid:
>
> <Fruit>
> <Name>Apple</Name>
> <Abbrev>APL</Abbrev>
> </Fruit>
>
> (NOTE: Now I'm getting hungry)
>
> while the following is considered invalid:
>
> <Fruit>
> <Name>Apple</Name>
> <Abbrev>ORG</Abbrev>
> </Fruit>
>
> Kind Regards,
> Joe Chiusano
> Booz | Allen | Hamilton
> Strategy and Technology Consultants to the World
>
> Robert Koberg wrote:
> >
> > Couldn't you do:
> >
> > <xs:complexType name="Fruit">
> > <xs:choice>
> > <xs:group ref="apple"/>
> > <xs:group ref="orange"/>
> > </xs:choice>
> > </xs:complexType>
> >
> > <xs:group name="apple">
> > <xs:element name="Apple" type="xs:string"/>
> > <xs:element name="APL" type="xs:token"/>
> > </xs:group>
> >
> > <xs:group name="orange">
> > <xs:element name="Orange" type="xs:string"/>
> > <xs:element name="ORG" type="xs:token"/>
> > </xs:group>
> >
> > Maybe I missed something?
> >
> > best,
> > -Rob
> >
> > Chiusano Joseph wrote:
> >
> > > I was also just reminded that this can also be done with RNG (I knew
> > > there was another one!).
> > >
> > > Kind Regards,
> > > Joe Chiusano
> > > Booz | Allen | Hamilton
> > > Strategy and Technology Consultants to the World
> > >
> > > Joseph Chiusano wrote:
> > >
> > >>Using elements as data rather than metadata - very offensive indeed.
;)
> > >>
> > >>There is no solution for this with W3C Schema, but it can be done with
> > >>Schematron.
> > >>
> > >>Kind Regards,
> > >>Joe Chiusano
> > >>Booz | Allen | Hamilton
> > >>Strategy and Technology Consultants to the World
> > >>
> > >>Linda Grimaldi wrote:
> > >>
> > >>>I have been out of the XML world for a little while now, but someone
just asked me a question and I have to admit, it's going to keep me up
tonight if I can't come up with a better solution. And I'm a little rusty,
to boot...
> > >>>
> > >>>The issue is one of data dependency and validation. The goal is to
enforce a restriction on pairs of data values- if the data associated with
the node <Fruit><Name> is "Apple", then the value of the sibling node
<Fruit><Abbrev> must be "APL". Effectively, the goal is to enforce a
specific mapping from one enum into another within an XML document. The only
way my associate could figure to capture this dependency is as follows:
> > >>>
> > >>><xs:complexType name="Fruit">
> > >>> <xs:annotation>
> > >>> <xs:documentation>Defines the valid values for fruit
types</xs:documentation>
> > >>> </xs:annotation>
> > >>> <xs:choice>
> > >>> <xs:element name="APL" type="xs:token"
fixed="Apple"/>
> > >>> <xs:element name="ORG" type="xs:token"
fixed="Orange"/>
> > >>> <xs:element name="BAN" type="xs:token"
fixed="Banana"/>
> > >>> <xs:element name="LEM" type="xs:token"
fixed="Lemon"/>
> > >>> <xs:element name="GRP" type="xs:token"
fixed="Grape"/>
> > >>> </xs:choice>
> > >>></xs:complexType>
> > >>>
> > >>>All in all, this strikes me as a very ugly, even offensive, solution.
My initial response was to forget about the validation- it wasn't worth it.
Is there a way to preserve the data dependency validation without warping
the instance document as the above schema fragment would require?
> > >>>
> > >>>Thanks,
> > >>>Linda
> > >>>
> >
> > >
>
> --
> Kind Regards,
> Joseph Chiusano
> Associate
> Booz | Allen | Hamilton
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
>
>
|