RE: [xsl] Using keys to lookup from current stylesheet

Subject: RE: [xsl] Using keys to lookup from current stylesheet
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 10 Nov 2003 11:43:05 -0000
> 
> Isn't this a case of keys across documents Michael?
> He did say the acronym list was in another stylesheet.

His key() function only needs to search one document, so it's not a
problem.

Michael Kay


> 
> regards DaveP
> 
> 
> 
> > This works for me. If I add the template rule
> > 
> >     <xsl:template match="/">
> >       <xsl:call-template name="AcronymnStandsFor">
> >         <xsl:with-param name="acronym" select="'Ant'"/>
> >       </xsl:call-template>
> >     </xsl:template>
> > 
> > and run it under Saxon 6.5.3, with any source document, it produces
> > 
> > <?xml version="1.0" encoding="utf-8"?>Another Neat Tool
> > 
> > Michael Kay
> > 
> > > -----Original Message-----
> > > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> > > Justin Makeig
> > > Sent: 07 November 2003 21:36
> > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > Subject: [xsl] Using keys to lookup from current stylesheet
> > > 
> > > 
> > > I'm trying to use a key to lookup elements in the current
> > > stylesheet. The AcronymnStandsFor is called from another 
> > > stylesheet that imports the one shown below to populate the 
> > > @title attribute of xhtml:acronym elements. I've used Michael 
> > > Kay's advice from his book and used the for-each 
> > > select="document('')" to switch the context to the current 
> > > (stylesheet) document. However, the key doesn't seem to find 
> > > anything. I've tested that the values that are coming in in 
> > > the $acronym parameter are correct. Can anybody spot what the 
> > > problem might be? Thanks.
> > > 
> > > - Justin
> > > 
> > > <xsl:stylesheet version="1.0"
> > >     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> > >     xmlns:a="http://cde.berkeley.edu/docbook/constant/acronym";
> > >     exclude-result-prefixes="a">
> > >     
> > >     <xsl:key name="AcronymKey" match="a:acronymItem"
> > use="a:acronym"/>
> > >     
> > >     <xsl:template name="AcronymnStandsFor">
> > >         <xsl:param name="acronym"/>
> > >         <!-- change context to current document so the key
> > > will work -->
> > >         <xsl:for-each select="document('')">
> > >             <xsl:value-of 
> > > select="key('AcronymKey',$acronym)/a:standsFor"/>
> > >         </xsl:for-each>
> > >     </xsl:template>
> > >     
> > >     <!-- acronym lookups -->
> > >     <a:acronymList>
> > >         <a:acronymItem>
> > >             <a:acronym>Ant</a:acronym>
> > >             <a:standsFor>Another Neat Tool</a:standsFor>
> > >         </a:acronymItem>
> > >         ...
> > >     </a:acronymList>
> > > </xsl:stylesheet>
> > > 
> > > 
> > >  XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
> > 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> - 
> DISCLAIMER: 
> 
> NOTICE: The information contained in this email and any 
> attachments is 
> confidential and may be privileged. If you are not the intended 
> recipient you should not use, disclose, distribute or copy any of the 
> content of it or of any attachment; you are requested to notify the 
> sender immediately of your receipt of the email and then to delete it 
> and any attachments from your system. 
> 
> RNIB endeavours to ensure that emails and any attachments 
> generated by 
> its staff are free from viruses or other contaminants. However, it 
> cannot accept any responsibility for any  such which are 
> transmitted. We therefore recommend you scan all attachments. 
> 
> Please note that the statements and views expressed in this email and 
> any attachments are those of the author and do not 
> necessarily represent 
> those of RNIB. 
> 
> RNIB Registered Charity Number: 226227 
> 
> Website: http://www.rnib.org.uk 
> 
>  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