W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2005

Re: Facets

From: Kasimier Buchcik <kbuchcik@4commerce.de>
Date: Thu, 17 Feb 2005 20:40:23 +0100
Message-ID: <4214F327.2070308@4commerce.de>
To: Farid.Mahini@L-3com.com
CC: xmlschema-dev@w3.org

Hi,

Farid.Mahini@L-3com.com wrote:
> Thank you for your comment.
> 
> I am planning on using this method (actually currently in the middle of
> Michael Kay's XSLT2.0 book) in the way you mentioned it:
> 
> I am creating XML files for running tests on various 'boxes' which have
> different configurations (#of cards, channels, so on). I was planning on
> using the XSLT to create the hardware dependant schema using user hardware
> selection.  It seems I am on the righttrack on that section of the task. 
> 
> However, within each XML document, the user defines their own set of
> definitions to be used as enum values.  Michael Kay suggested using the
> 'key/keyref' elements; I tried it, but XMLSpy  seems to validate it even
> though I intentionally used an invalid attribute. I am new at this and could
> be my code.  Please point my error in the following example I used to test
> the key/keyref element? 
> 
> The schema:
> <xs:schema  ....>
> 	<xs:element name="Measurements">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element name="AAA" type="myAAA"/>
> 				<xs:element name="BBB" type="myBBB"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 		<xs:key name="myId">
> 			<xs:selector xpath="./AAA/a"/>
> 			<xs:field xpath="@a"/>
> 		</xs:key>
> 		<xs:keyref name="myIdref" refer="myId">
> 			<xs:selector xpath="./BBB/b"/>
> 			<xs:field xpath="@b"/>
> 		</xs:keyref>
> 	</xs:element>
> 	<xs:complexType name="myAAA">
> 		<xs:sequence>
> 			<xs:element name="a" maxOccurs="unbounded">
> 				<xs:complexType>
> 					<xs:attribute name="id"
> type="xs:string" use="required"/>
> 				</xs:complexType>
> 			</xs:element>
> 		</xs:sequence>
> 	</xs:complexType>
> 	<xs:complexType name="myBBB">
> 		<xs:sequence>
> 			<xs:element name="b" maxOccurs="unbounded">
> 				<xs:complexType>
> 					<xs:attribute name="idref"
> type="xs:string" use="required"/>
> 				</xs:complexType>
> 			</xs:element>
> 		</xs:sequence>
> 	</xs:complexType>
> </xs:schema>
> 
> 
> The XML input doucment:
> <Measurements .....>
>   <AAA> 
>     <a id="x"/> 
>     <a id="y"/> 
>   </AAA> 
>   <BBB> 
>     <b idref="x"/> 
>     <b idref="y"/> 
>     <b idref="z"/>    // should cause an error since only 'x' and 'y' are
> valid choices.
>   </BBB>
> 
> </Measurements>
[...]

XMLSpy does not evaluate this correctly. The XPath expression of the IDC
fields used here should resolve to the attributes "a" or "b" only.
If those XPath expressions are substituted for "@id" and "@idref" I get
keyref error you expected with Libxml2, Xerces 2.6.2 and XSV 2.7.

Regards,

Kasimier
Received on Thursday, 17 February 2005 19:40:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:49 GMT