xsl-list
[Top] [All Lists]

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

2006-12-20 07:08:26
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[(_at_)id = $this]/catDesc"/> 
  </xsl:for-each> 
</xsl:template> 

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

-----Original Message-----
From: James Cummings [mailto:cummings(_dot_)james(_at_)gmail(_dot_)com] 
Sent: 20 December 2006 13:52
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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[(_at_)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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--