- From: Priscilla Walmsley <priscilla@walmsley.com>
- Date: Wed, 22 Aug 2001 20:23:34 -0400
- To: <kboo@ca.ibm.com>, "'Henry S. Thompson'" <ht@cogsci.ed.ac.uk>
- Cc: "'Jun Wang'" <t-junw@microsoft.com>, "'Aung Aung'" <aaung@microsoft.com>, <xmlschema-dev@w3.org>
Right, I see. I assumed that the example was intended to show a and b as siblings. But since no type is specified for the element "b", it is unconstrained - it can contain any elements and have any attributes. This means that it might contain "a", in which case it would be valid. For example : <root> <b keyref="ABC"> <a key="ABC"/> </b> </root> is valid if the schema is: <xsd:schema> <xsd:element name="root"/> <xsd:element name="a"> <xsd:key name="A"> <xsd:selector xpath="."/> <xsd:field xpath="@key"/> </xsd:key> </xsd:element> <xsd:element name="b"> <xsd:keyref name="B" refer="A"> <xsd:selector xpath="."/> <xsd:field xpath="@keyref"/> </xsd:keyref> </xsd:element> </xsd:schema> However, the following two instances would _not_ be valid: <root> <a key="ABC"> <b keyref="ABC"/> </a> </root> <root> <b keyref="ABC"/> <a key="ABC"/> </root> (But this last example could be remedied by defining the constraints within the "root" element instead.) ----------------------------------------------------------- Priscilla Walmsley priscilla@walmsley.com Architect, Vitria Technology http://www.vitria.com Author, Definitive XML Schema (Prentice Hall, Dec. 2001) ----------------------------------------------------------- > -----Original Message----- > From: xmlschema-dev-request@w3.org > [mailto:xmlschema-dev-request@w3.org]On Behalf Of kboo@ca.ibm.com > Sent: Wednesday, August 22, 2001 5:59 PM > To: Henry S. Thompson > Cc: Jun Wang; Aung Aung; xmlschema-dev@w3.org > Subject: Re: key/keyref problem > > > > > Part II: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Aung: > > >> How about this: should this work? (how/why?) > > >> C: > > >> <root> > > >> <element name="a"> > > >> <key name="A"> > > >> </element> > > >> <element name="b"> > > >> <keyref refer="A"> > > >> </element> > > >> </root> > > > > Priscilla: > > > No, because the key and keyref have to be defined in the > same element, > > or > > the key has to be defined in a child element. Neither is > the case here. > > > ht: > > Not quite, Priscilla -- since <b> is unconstrained, in a valid > > instance an <a> might occur inside it, so the above is OK. > > Could you give me an example of a valid instance that shows > the above is > ok? > - Ki > >
Received on Wednesday, 22 August 2001 20:21:23 UTC