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

RE: Facets (resolved)

From: <Farid.Mahini@L-3com.com>
Date: Tue, 22 Feb 2005 09:44:00 -0500
Message-ID: <F00F0521BE28134DA357DC1DF7475B9901AAA740@texchg.te.l-3com.com>
To: xmlschema-dev@w3.org

With your help I was able to resolve this issue.

Thank you to all who provided comments and detail explaination.  

Farid Mahini
L3 Communications - Telemetry East
1515 Grundy's Lane, Bristol,  PA.  19007


> -----Original Message-----
> From: richard.liu@ubs.com [mailto:richard.liu@ubs.com]
> Sent: Tuesday, February 22, 2005 4:14 AM
> To: Farid.Mahini@L-3com.com
> Subject: RE: Facets
> 
> 
> Hi Farid,
> 
> There's a namespace problem in the your constraints.  In your 
> schema you specify a default namespace, but in the 
> constraints the namespace must be explicit.  Without a 
> namespace prefix the constraints are being interpreted as 
> referring to elements in no namespace.  I've corrected the 
> problem and the example now works as you expect.
> 
> Regards,
> Richard
> 
> > -----Original Message-----
> > From: Farid.Mahini@L-3com.com [mailto:Farid.Mahini@L-3com.com]
> > Sent: Monday, February 21, 2005 18:27
> > To: Liu, Richard
> > Subject: RE: Facets
> > 
> > 
> > Richard,
> > 
> > I created the attached file by pasting your code into 
> > them(did change the
> > xsi:schemaLocation in XML input file).  I do not get the same 
> > behavior!
> > Please validate them in your system to see if I goofed ( 
> ican not see
> > where).  I also added the invlaid measurement and it still 
> > validated.  I am
> > using the XMLSpy 2005 SP2 Home Edition. According to Altova, 
> > validation is
> > the same in all versions (Home, Entr. or Prof.).
> > 
> > Thanx a mil.
> > -Farid
> > 
> > > -----Original Message-----
> > > From: richard.liu@ubs.com [mailto:richard.liu@ubs.com]
> > > Sent: Monday, February 21, 2005 11:46 AM
> > > To: Farid.Mahini@L-3com.com
> > > Subject: RE: Facets
> > > 
> > > 
> > > Hi Farid,
> > > 
> > > Just checked my example again by adding this measurement:
> > > 
> > > 	<measurement>
> > > 		<name>invalid</name>
> > > 		<type>invalid</type>
> > > 	</measurement>
> > > 
> > > Xmlspy 2005 sp2 correctly complains that "The value 'invalid' 
> > > matched by the <keyref> identity constraint 'measurementType' 
> > > was not matched by the referenced key 'validType' within the 
> > > scope of element 'measurements'."  Unless I misunderstood, 
> > > this is the behavior you wanted.  Of course, my type is a 
> > > child element, not an attribute, but I think the example 
> > > could be reformulated to work with attributes.
> > > 
> > > Regards,
> > > Richard
> > > 
> > > > -----Original Message-----
> > > > From: Farid.Mahini@L-3com.com [mailto:Farid.Mahini@L-3com.com]
> > > > Sent: Monday, February 21, 2005 17:18
> > > > To: Liu, Richard
> > > > Cc: xmlschema-dev@w3.org
> > > > Subject: RE: Facets
> > > > 
> > > > 
> > > > Hi Richard,
> > > > 
> > > > Your schema does not seem to connect the content of 
> > > > 'validTypes' and the
> > > > vlaues used in the 'measurement/type' element.  I.e. your XMl 
> > > > document will
> > > > validate using this schema even if the value of type is 
> not one of
> > > > validTypes.  I am not sure this the right way of doing it or 
> > > > not, but seems
> > > > to tie the validTypes and measurement/type.
> > > > 
> > > > 
> > > > XML Schema:
> > > > 
> > > > <xs:schema ......>
> > > > 	<xs:element name="Measurements">
> > > > 		<xs:complexType>
> > > > 			<xs:sequence>
> > > > 				<xs:element name="validTypes" 
> > > > type="myAAA"/>
> > > > 				<xs:element name="measurement" 
> > > > type="myBBB"
> > > > maxOccurs="unbounded"/>
> > > > 			</xs:sequence>
> > > > 		</xs:complexType>
> > > > 		<xs:key name="myId">
> > > > 			<xs:selector xpath="./validTypes/type"/>
> > > > 			<xs:field xpath="@hwType"/>
> > > > 		</xs:key>
> > > > 		<xs:keyref name="myIdref" refer="myId">
> > > > 			<xs:selector 
> xpath="./measurement/name"/>
> > > > 			<xs:field xpath="@hwType"/>
> > > > 		</xs:keyref>
> > > > 	</xs:element>
> > > > 	<xs:complexType name="myAAA">
> > > > 		<xs:sequence>
> > > > 			<xs:element name="type" 
> maxOccurs="unbounded"/>
> > > > 		</xs:sequence>
> > > > 	</xs:complexType>
> > > > 	<xs:complexType name="myBBB">
> > > > 		<xs:sequence>
> > > > 			<xs:element name="name"/>
> > > > 		</xs:sequence>
> > > > 	</xs:complexType>
> > > > 	<xs:attribute name="hwType" type="xs:string"/>
> > > > </xs:schema>
> > > > 
> > > > 
> > > > 
> > > > 
> > > > XML input:
> > > > 
> > > > </Measurements......>
> > > >   <validTypes>
> > > >     <type hwType="analog"/> 
> > > >     <type hwType="digital"/>
> > > >     <type hwType="undefined"/> 
> > > >   </validTypes> 
> > > >   <measurement> 
> > > >     <name hwType="analog">Flow</name> 
> > > >   </measurement>
> > > >   <measurement> 
> > > >     <name hwType="digital">Heading</name> 
> > > >   </measurement>
> > > >   <measurement> 
> > > >     <name hwType="bus">Alt</name> 
> > > >   </measurement> 
> > > > </Measurements>
> > > > 
> > > > -Farid
> > > > 
> > > > 
> > > > > -----Original Message-----
> > > > > From: richard.liu@ubs.com [mailto:richard.liu@ubs.com]
> > > > > Sent: Friday, February 18, 2005 5:49 AM
> > > > > To: kbuchcik@4commerce.de; Farid.Mahini@L-3com.com
> > > > > Cc: xmlschema-dev@w3.org
> > > > > Subject: RE: Facets
> > > > > 
> > > > > 
> > > > > This seems to do what Farid wanted, and it validates in 
> > > > > xmlspy 2005 sp2:
> > > > > 
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> > > > > elementFormDefault="qualified" 
> > attributeFormDefault="unqualified">
> > > > > 	<xs:element name="measurements">
> > > > > 		<xs:annotation>
> > > > > 			<xs:documentation>Testing my 
> > > > > understanding of xs:key and xs:keyref.  If this works, it 
> > > > > could become the basis for translating an FDDL into an XML 
> > > > > schema.</xs:documentation>
> > > > > 		</xs:annotation>
> > > > > 		<xs:complexType>
> > > > > 			<xs:sequence>
> > > > > 				<xs:element name="validTypes">
> > > > > 					<xs:complexType>
> > > > > 						<xs:sequence>
> > > > > 							
> > > > > <xs:element name="validType" type="xs:string" 
> > > > maxOccurs="unbounded"/>
> > > > > 						</xs:sequence>
> > > > > 					</xs:complexType>
> > > > > 				</xs:element>
> > > > > 				<xs:element name="measurement" 
> > > > > maxOccurs="unbounded">
> > > > > 					<xs:complexType>
> > > > > 						<xs:sequence>
> > > > > 							
> > > > > <xs:element name="name" type="xs:string"/>
> > > > > 							
> > > > > <xs:element name="type" type="xs:string"/>
> > > > > 						</xs:sequence>
> > > > > 					</xs:complexType>
> > > > > 				</xs:element>
> > > > > 			</xs:sequence>
> > > > > 		</xs:complexType>
> > > > > 		<xs:key name="validType">
> > > > > 			<xs:selector 
> > xpath="validTypes/validType"/>
> > > > > 			<xs:field xpath="."/>
> > > > > 		</xs:key>
> > > > > 		<xs:keyref name="measurementType" 
> > refer="validType">
> > > > > 			<xs:selector xpath="measurement"/>
> > > > > 			<xs:field xpath="type"/>
> > > > > 		</xs:keyref>
> > > > > 	</xs:element>
> > > > > </xs:schema>
> > > > > 
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <!-- edited with XMLSpy v2005 sp2 U (http://www.altova.com) 
> > > > > by Rene Brunner (UBS AG) -->
> > > > > <measurements 
> > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> > > > > xsi:noNamespaceSchemaLocation="D:\My 
> > > > > Documents\Work\WBml\Forms\Schema\keyrefTest.xsd">
> > > > > 	<validTypes>
> > > > > 		<validType>analog</validType>
> > > > > 		<validType>digital</validType>
> > > > > 		<validType>bus</validType>
> > > > > 		<validType>undefined</validType>
> > > > > 	</validTypes>
> > > > > 	<measurement>
> > > > > 		<name>airflow</name>
> > > > > 		<type>analog</type>
> > > > > 	</measurement>
> > > > > 	<measurement>
> > > > > 		<name>heading</name>
> > > > > 		<type>digital</type>
> > > > > 	</measurement>
> > > > > </measurements>
> > > > > 
> > > > > Regards,
> > > > > Richard
> > > > > 
> > > > > > -----Original Message-----
> > > > > > From: xmlschema-dev-request@w3.org
> > > > > > [mailto:xmlschema-dev-request@w3.org]On Behalf Of 
> > > Kasimier Buchcik
> > > > > > Sent: Thursday, February 17, 2005 20:40
> > > > > > To: Farid.Mahini@L-3com.com
> > > > > > Cc: xmlschema-dev@w3.org
> > > > > > Subject: Re: Facets
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 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
> > > > > > 
> > > > > > 
> > > > > 
> > > > 
> > > > 
> > > > From E-mail Administrator
> > > > ATTENTION PLEASE: Do you have our new e-mail addresses?
> > > > The current L-3 standard is First.Last @ L-3com.com
> > > > E-mail addressed to First.Last @ te.L-3com.com will no longer 
> > > > be delivered.
> > > > Please update your address book using the "From" address on 
> > > > this email.
> > > > 
> > > > 
> > > > 
> > > 
> > 
> > 
> > From E-mail Administrator
> > ATTENTION PLEASE: Do you have our new e-mail addresses?
> > The current L-3 standard is First.Last @ L-3com.com
> > E-mail addressed to First.Last @ te.L-3com.com will no longer 
> > be delivered.
> > Please update your address book using the "From" address on 
> > this email.
> > 
> > 
> >     
> > 
> > 
> 


>From E-mail Administrator
ATTENTION PLEASE: Do you have our new e-mail addresses?
The current L-3 standard is First.Last @ L-3com.com
E-mail addressed to First.Last @ te.L-3com.com will no longer be delivered.
Please update your address book using the "From" address on this email.
Received on Tuesday, 22 February 2005 14:44:16 GMT

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