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

Re: current() within a key element's @use

Subject: Re: current() within a key element's @use
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 28 Dec 2012 09:31:45 -0800
Re:  current() within a key element's @use
On Fri, Dec 28, 2012 at 8:38 AM, Chris Maloney <voldrani@xxxxxxxxx> wrote:
> As for a work-around, the following works with xsltproc, but
> interestingly, not with Saxon.  Saxon complains "key() function cannot
> be used here".  (This is a variant of the XSLT that Dimitre posted on
> SO):
>
>
>     <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output omit-xml-declaration="yes" indent="yes"/>
>
>       <xsl:key name='kTagUsage' match='tagUsage' use='@render'/>
>       <xsl:key name="kRendByUsageGi" match="rendition"
>         use="key('kTagUsage', @xml:id)/@gi"/>
>
>       <xsl:template match="/">
>         <xsl:copy-of select="key('kRendByUsageGi', 'p')/text()"/>
>         ========
>         <xsl:copy-of select="key('kRendByUsageGi', 'emph')/text()"/>
>       </xsl:template>
>     </xsl:stylesheet>
>

There is a "slight" difference: I didn't use key() inside the
expression in the "use"  attribute (I believe the error is raised to
prevent cirkular key definition) -- and the below transformation is
working with Saxon:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:key name="kRendByUsageGi" match="rendition"
  use="../tagUsage[@render=current()/@xml:id]/@gi"/>

 <xsl:template match="/">
  <xsl:copy-of select="key('kRendByUsageGi', 'p')/text()"/>
========
  <xsl:copy-of select="key('kRendByUsageGi', 'emph')/text()"/>
 </xsl:template>
</xsl:stylesheet>


Cheers,

Dimitre

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.