[
Lists Home |
Date Index |
Thread Index
]
Thanks, I read HT's mail also. The main thing I was trying to see was:
how to define keyrefs to "relative keys" (scope is not root element); same
scope is perfectly fine..
if you define keyrefs on different scopes, then you run into problems.
Important point worth double-checking and for all of us to note, I felt..
note; we can have key on an "ancestor" scope, and a keyref on a
"descendant scope".. i guess that is not allowed right now.. in most such
cases, we can move the keyref to the ancestor scope.. right??
best, murali.
> Second, a keyref can only refer to a key defined in the same scope.
>
> Third, even if you move the key and keyref into the same scope, the keys
> in your example are not unique. Two of them have the value "1".
>
> It seems likely that you didn't think this should be valid when you
> posed it, as you know perfectly well that the state code must be
> combined with plateNumber to make a unique key. Must be a "teaching
> example". ;-}
>
> Bob Foster
>
> Murali Mani wrote:
>
> > I have a question on XML-Schema:
> >
> > Is it possible to have:
> >
> > <xs:element name="vehicle">
> > <xs:complexType>
> > <xs:attribute name="plateNumber" type="xs:integer"/>
> > </xs:complexType>
> > </xs:element>
> >
> > <xs:element name="state">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="code" type="xs:string"/>
> > <xs:element ref="vehicle" maxOccurs="unbounded"/>
> > </xs:sequence>
> > </xs:complexType>
> >
> > <xs:key name="reg">
> > <xs:selector xpath=".//vehicle"/>
> > <xs:field xpath="@plateNumber"/>
> > </xs:key>
> > </xs:element>
> >
> > <xs:element name="person">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="car" maxOccurs="unbounded"/>
> > <xs:complexType>
> > <xs:attribute name="regPlate" type="xs:integer"/>
> > </xs:complexType>
> > </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> >
> > <xs:keyRef name="carRef" refer="reg">
> > <xs:selector xpath=".//car"/>
> > <xs:field xpath=@regPlate"/>
> > </xs:keyRef>
> > </xs:element>
> >
> > Is the above a correct schema. And in that case can I have a document like
> >
> > <root>
> > <state>
> > <code>CA</code>
> > <vehicle plateNumber="1"/>
> > <vehicle plateNumber="2"/>
> > </state>
> > <state>
> > <code>MA</code>
> > <vehicle plateNumber="1"/>
> > </state>
> >
> > <person>
> > <car regPlate="1"/>
> > </person>
> > <person>
> > <car regPlate="2"/>
> > </person>
> > </root>
> >
> > is this a valid instance for that schema??
> >
> > thanks, murali.
>
>
|