[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Schema keys and XSLT implementation

Subject: RE: Schema keys and XSLT implementation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 28 Jul 2005 09:10:22 +0100
zap2it xml download
> I have a XLST that reads XML from zap2it.com (via SOAP) and I 
> declare several keys.  I was reading 
> their schema and it also has similar 'xsd:key', 'xsd:keyref', 
> and 'xsd:unique' elements.  My question 
> is -- is my xsl:key statements redundant?  And can I just 
> phrase a "key()" search function based on 
> the schema, or is the schema for documentation only?

The keys defined in the schema are there for validation purposes, while the
keys defined in the stylesheet declare indexes for efficient access. They
have no relationship to each other.

A schema-aware XSLT processor could make use of the existence of keys in the
schema to create implicit indexes for efficient access in your stylesheet,
but the only schema-aware XSLT processor currently in existence (Saxon-SA)
doesn't (yet) do that.

An XSLT 1.0 processor such as libxslt is very unlikely to make any use of
schema information, though it could do so in theory.

Michael Kay
http://www.saxonica.com/


> 
> I have read "XSL Transformations" 
> (http://www.w3.org/TR/xslt), but they dont mention a schema 
> connection.
> 
> BTW, this is a general XSLT language question ... but if it 
> depends on implementation I am using 
> xmlsoft.org (aka. Gnome) libxslt v1.1.12.
> 
> 
> These are my xsl:key statements:
>    <xsl:key name="station_keyref_schedule" 
> match="./ns1:schedules/ns1:schedule" use="@station" /> 
>    <xsl:key name="program_key" 
> match="./ns1:programs/ns1:program" use="@id" /> 
>    <xsl:key name="genre_keyref" 
> match="./ns1:genres/ns1:programGenre" use="@program" /> 
>    <xsl:key name="crew_keyref" 
> match="./ns1:productionCrew/ns1:crew" use="@program" /> 
> 
> 
> And the relevant schema portion 
> (http://docs.tms.tribune.com/tech/xml/schemas/tmsxtvd.xsd):
> 
> <xsd:key name="station_key"> 
>    <xsd:selector xpath="./stations/station"/> 
>    <xsd:field xpath="@id"/> 
> </xsd:key> 
> <xsd:keyref name="station_keyref_schedule" refer="tms:station_key"> 
>    <xsd:selector xpath="./schedules/schedule"/> 
>    <xsd:field xpath="@station"/> 
> </xsd:keyref> 
> <xsd:unique name="program_key"> 
>    <xsd:selector xpath="./programs/program"/> 
>    <xsd:field xpath="@id"/> 
> </xsd:unique> 
> <xsd:keyref name="crew_keyref" refer="tms:program_key"> 
>    <xsd:selector xpath="./productionCrew/crew"/> 
>    <xsd:field xpath="@program"/> 
> </xsd:keyref> 
> <xsd:keyref name="genre_keyref" refer="tms:program_key"> 
>    <xsd:selector xpath="./genres/programGenre"/> 
>    <xsd:field xpath="@program"/> 
> </xsd:keyref> 
> 
> 
> The XML outline is:
> 
> <xtvd from='2005-07-20T11:30:00Z' to='2005-07-21T00:00:00Z' 
> schemaVersion='1.3' xmlns='urn:
> TMSWebServices' 
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
> xsi:schemaLocation='urn:
> TMSWebServices 
> http://docs.tms.tribune.com/tech/xml/schemas/tmsxtvd.xsd'>
> ...
> <stations> 
>   <station id="10398"> 
>     
> <callSign>KDAF</callSign><name>KDAF</name><fccChannelNumber>33
</fccChannelNumber><affiliate>WB 
> Affiliate</affiliate> 
>   </station> 
>   <station id="10402"> 
>     
> <callSign>KDFW</callSign><name>KDFW</name><fccChannelNumber>4<
/fccChannelNumber><affiliate>Fox 
> Affiliate</affiliate> 
>   </station> 
> </stations> 
> <schedules><schedule program="SH6948700000" station="10398" 
> time="2005-07-20T11:30:00Z" 
> duration="PT00H30M"/> 
> ... 
> <schedule program="SH1966900000" station="10402" 
> time="2005-07-20T11:00:00Z" duration="PT01H00M"/> 
> ... 
> </schedules> 
> <programs> 
> ... 
> <program id="EP0000510180"><title>A Different 
> World</title><subtitle>When One Door Closes ...
> <subtitle><description>A Japanese corporation woos Dwayne for 
> his software; Whitley is pregnant; 
> guests Diahann Carroll, Patti 
> LaBelle.</description><showType>Series</showType><series>SH000051</
> series><syndicatedEpisodeNumber>9216B</syndicatedEpisodeNumber
> ><originalAirDate>1993-05-08</
> originalAirDate></program> 
> ... 
> <program id="SH1966900000"><title>Good Day at 
> 6:00AM</title><description>Henderson, Ryan.</
> description><showType>Series</showType><series>SH196690</serie
s><originalAirDate>2001-06-21</
> originalAirDate></program> 
> ... 
> </programs> 
> <productionCrew><crew 
> program="EP0000510180"><member><role>Actor</role><givenname>Jasmine</
> givenname><surname>Guy</surname></member> 
> ... 
> </crew> 
> ... 
> </productionCrew> 
> <genres><programGenre 
> program="EP0000510180"><genre><class>Sitcom</class><relevance>
0</relevance></
> genre></programGenre> 
> ... 
> </genres> 
> </xtvd>
> 
> 
> Thx for any pointers ....
> -- 
> Rodman

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.