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

RE: key definition

Subject: RE: key definition
From: "Chris Bayes" <chris@xxxxxxxxxxx>
Date: Sun, 28 Oct 2001 14:17:18 -0000
rekey definition
Steve,
1.
<xsl:key name="MyKey" match="/items/item" use="concat(data/@id,
data/text())" />
2.
<xsl:key name="MyKey" match="/items/item" use="concat(pad(data/@id),
data/text())" />
Where pad() is an extension function or concat(substring('000000', 7 -
string-length(data/@id), data/@id)

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Steve Renshaw
> Sent: 28 October 2001 13:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  key definition
> 
> 
> Given the following XML:
> 
>    <items>
>     <item>
>     <data id="1">alpha</data>
>     <data id="2">gamma</data>
>     </item>
>     <item>
>     <data id="1">alpha</data>
>     <data id="2">delta</data>
>     </item>
>     <item>
>     <data id="1">beta</data>
>     <data id="2">gamma</data>
>     </item>
>    </items>
> 
> I am searching for a key definition that will return the set 
> of <item>'s that have a given @id and <data> value. I want to 
> use key() in the following 
> manner:
> 
>    given variables $id and $value
>    select="key('MyKey',concat($id,$value))"
> 
>    examples
>    select="key('MyKey',concat('1','alpha'))
>    returns the first and second <item>'s
> 
>    select="key('MyKey',concat('2','gamma'))
>    returns the first and third <item>'s
> 
> Anyone know how to complete this definition (or suggest another)?
> 
>   <xsl:key name="MyKey" match="/items/item" use="?" />
> 
> Second question: What happens if I encounter markup that looks like
> this:
> 
>    <item>
>     <data id="1">01</data>
>     <data id="10">1</data>
>    </item>
> 
> in which case the usage of concat($id,$value) aliases into "101"
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at 
> http://explorer.msn.com/intl.asp
> 
> 
>  XSL-List info and 
> archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.