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

RE: XSLT2, select nodes inside a tokenize()'d variable

Subject: RE: XSLT2, select nodes inside a tokenize()'d variable
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 20 Dec 2006 14:08:10 -0000
RE:  XSLT2
Just bind a variable outisde the for-each, and use that:

<xsl:template name="makeSegLabel">
 <xsl:variable name="this" select="."/>
 <xsl:variable name="ana" select="tokenize(@ana, '(\s+)')"/> 
  <xsl:for-each select="$ana">
    <xsl:value-of select="$this"/><xsl:text>:</xsl:text>
    <xsl:value-of select="root($this)//category[@id = $this]/catDesc"/> 
  </xsl:for-each> 
</xsl:template> 

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

> -----Original Message-----
> From: James Cummings [mailto:cummings.james@xxxxxxxxx] 
> Sent: 20 December 2006 13:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT2, select nodes inside a tokenize()'d variable
> 
> Hiya,  I'm sure I'm just looking at this upside down, but here goes:
> 
> I want to do something like this:
> 
> <xsl:template name="makeSegLabel">
> <xsl:variable name="ana" select="tokenize(@ana, '(\s+)')"/> 
> <xsl:for-each select="$ana">
>   <xsl:value-of select="."/><xsl:text>:</xsl:text>
>   <xsl:value-of select="//category[@id = .]/catDesc"/> 
> </xsl:for-each> </xsl:template>
> 
> Where I want to tokenize the ana attribute on the element 
> which called this template, and then for each whitespace 
> separated value, I want to put it out, and then go get a 
> description of what that value means from elsewhere in the document.
> 
> However, I'm rightly told that I cannot select a node here 
> because the context is an atomic value.
> 
> I'm sure I'm being stupid and there is a better way to do this.
> 
> Suggestions?
> 
> Many thanks,
> -James
> --
> James Cummings, Cummings dot James at GMail dot com

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.