Subject: RE: [xsl] key definition From: "Chris Bayes" <chris@xxxxxxxxxxx> Date: Sun, 28 Oct 2001 14:17:18 -0000 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] key definition, Steve Renshaw | Thread | RE: [xsl] key definition, Steve Renshaw |
[xsl] key definition, Steve Renshaw | Date | Re: [xsl] dd mmm yyyy Date converte, Goetz Bock |
Month |