- From: Marcus Smedman <smedman@home.se>
- Date: Fri, 21 May 2004 09:23:53 +0200
- To: <xmlschema-dev@w3.org>
- Cc: "'Marcus Smedman'" <smedman@home.se>
- Message-Id: <20040521072358.JISK2575.mxfep01.bredband.com@FETINGEN>
Hi, Here's a newbie question. I have an xml like this: <?xml version="1.0" encoding="UTF-8"?> <!--Sample XML file generated by XMLSPY v2004 rel. 2 U (http://www.xmlspy.com)--> <WWW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="keyref_test.xsd"> <AAA> <HHHs> <HHH> <JJJIDs> <JJJID>1</JJJID> <JJJID>2</JJJID> </JJJIDs> </HHH> <HHH> <JJJIDs> <JJJID>1</JJJID> <JJJID>2</JJJID> </JJJIDs> </HHH> </HHHs> <JJJs> <JJJ JJJID="1"> <LLL>String</LLL> </JJJ> <JJJ JJJID="2"> <LLL>String</LLL> </JJJ> </JJJs> </AAA> <BBB> <HHHs> <HHH> <JJJIDs> <JJJID>4</JJJID> <JJJID>5</JJJID> </JJJIDs> </HHH> <HHH> <JJJIDs> <JJJID>4</JJJID> <JJJID>5</JJJID> </JJJIDs> </HHH> </HHHs> <JJJs> <JJJ JJJID="4"> <LLL>String</LLL> </JJJ> <JJJ JJJID="5"> <LLL>String</LLL> </JJJ> </JJJs> </BBB> </WWW> It is validated against this schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="WWW"> <xs:complexType> <xs:sequence> <xs:element name="AAA" type="CCC" minOccurs="0"> <xs:key name="aJJJIDKey"> <xs:selector xpath="JJJs/JJJ"/> <xs:field xpath="@JJJID"/> </xs:key> <xs:keyref name="aJJJIDRef" refer="aJJJIDKey"> <xs:selector xpath="HHHs/HHH/JJJIDs/JJJID"/> <xs:field xpath="."/> </xs:keyref> </xs:element> <xs:element name="BBB" type="CCC" minOccurs="0"> <xs:key name="bJJJIDKey"> <xs:selector xpath="JJJs/JJJ"/> <xs:field xpath="@JJJID"/> </xs:key> <xs:keyref name="bJJJIDRef" refer="bJJJIDKey"> <xs:selector xpath="HHHs/HHH/JJJIDs/JJJID"/> <xs:field xpath="."/> </xs:keyref> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="CCC"> <xs:sequence> <xs:element ref="HHHs"/> <xs:element ref="JJJs" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:element name="HHHs"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="HHH"> <xs:complexType> <xs:sequence> <xs:element name="JJJIDs" minOccurs="0"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="JJJID" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="JJJs"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="JJJ"> <xs:complexType> <xs:sequence> <xs:element name="LLL" type="xs:string"/> </xs:sequence> <xs:attribute name="JJJID" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> What I want is to validate that all HHHs/HHH/JJJIDs exist in (the attribute) the list of JJJs/JJJ/JJJID and it works. My question, is there a way to declare a key/keyref for JJJIDKey that works for all CCC's. Above I've created a "aJJJIDKey", "bJJJIDKey" and I would like to get around this. Thanks Marcus
Received on Friday, 21 May 2004 04:48:02 UTC