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

RE: Facets

From: <Farid.Mahini@L-3com.com>
Date: Thu, 17 Feb 2005 12:12:40 -0500
Message-ID: <F00F0521BE28134DA357DC1DF7475B9901AAA731@texchg.te.l-3com.com>
To: noah_mendelsohn@us.ibm.com
Cc: xmlschema-dev@w3.org

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:element name="AAA" type="myAAA"/>
				<xs:element name="BBB" type="myBBB"/>
		<xs:key name="myId">
			<xs:selector xpath="./AAA/a"/>
			<xs:field xpath="@a"/>
		<xs:keyref name="myIdref" refer="myId">
			<xs:selector xpath="./BBB/b"/>
			<xs:field xpath="@b"/>
	<xs:complexType name="myAAA">
			<xs:element name="a" maxOccurs="unbounded">
					<xs:attribute name="id"
type="xs:string" use="required"/>
	<xs:complexType name="myBBB">
			<xs:element name="b" maxOccurs="unbounded">
					<xs:attribute name="idref"
type="xs:string" use="required"/>

The XML input doucment:
<Measurements .....>
    <a id="x"/> 
    <a id="y"/> 
    <b idref="x"/> 
    <b idref="y"/> 
    <b idref="z"/>    // should cause an error since only 'x' and 'y' are
valid choices.


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


> -----Original Message-----
> From: noah_mendelsohn@us.ibm.com [mailto:noah_mendelsohn@us.ibm.com]
> Sent: Thursday, February 17, 2005 10:57 AM
> To: Bryce K. Nielsen
> Cc: xmlschema-dev@w3.org
> Subject: Re: Facets
> Another way to do this, which may or may not be convenient, 
> is to use an 
> XSLT script to tailor a schema for each of your hardware 
> types.  XSLT can 
> read multiple documents, so you could have one input document 
> that's a 
> skeleton schema, and another with the constraint values, 
> using XSLT to 
> merge them.  If you prefer, you could burry the entire 
> skeleton into the 
> XSL stylesheet as a template, using a single input document 
> with the key 
> values. 
> --------------------------------------
> Noah Mendelsohn 
> IBM Corporation
> One Rogers Street
> Cambridge, MA 02142
> 1-617-693-4036
> --------------------------------------
> "Bryce K. Nielsen" <bryce@sysonyx.com>
> Sent by: xmlschema-dev-request@w3.org
> 02/16/05 12:42 AM
>         To:     <xmlschema-dev@w3.org>
>         cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
>         Subject:        Re: Facets
> > This method only works if I had previous knowledge of the enumerated
> values.
> > In my case users create their own set of Types (not a subset of
> acceptable
> > values by my schema, but literally using their own naming 
> conventions).
> For
> > instance, depending on the hardware under test, the user 
> will compose a
> > totally different measurement Types.
> >
> Ah. Well, W3C XML Schemas don't inhierently support this 
> "dynamic" schema
> contruction. You will probably need to use a stylesheet to 
> validate, or
> perhaps schematron.
> Bryce K. Nielsen
> SysOnyx, Inc. (www.sysonyx.com)
> Read the origins of xmlDraft, the Smart XSD Editor:
> http://www.sysonyx.com/xml-schema-editor

>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 Thursday, 17 February 2005 17:13:12 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:07 UTC