This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

XSLT doubt

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a basic XSLT example below. First I will show you the xml, then the xsl sheet, and then the ouput.
All these works fine.
But when I try to use a variable name, is not working.

<ColumnA>any value</ColumnA>
<ColumnC>any vlaue</ColumnC>
<ColumnA>any value</ColumnA>
<ColumnC>any value</ColumnC>
<ColumnA>any value</ColumnA>
<ColumnC>any value</ColumnC>

<xsl:stylesheet xmlns:xsl=""; version="1.0">
<xsl:template match="/page">
<!-- Any stuff -->

<!-- BODY -->
<xsl:call-template name="template2">
<xsl:with-param name="data" select="rows/row" />

<!-- Any stuff -->

<xsl:template name="template2">
<xsl aram name="data" />

<xsl:variable name="filter-column" select="group"/>
<xsl:variable name="filter-identifier" select="$data[1]/*[name() = $filter-column]"/>
<xsl:variable name="filtered-data" select="$data[ColumnB = $filter-identifier]"/>

<xsl:text> </xsl:text>
<xsl:value-of select="$filter-column"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$filter-identifier"/>
<xsl:text> </xsl:text>
<xsl:value-of select="count($filtered-data)"/>


This is all fine, but where I try to use a variable. Instead of:
<xsl:variable name="filtered-data" select="$data[ColumnB = $filter-identifier]"/>

Use this(changing just ColumnB literal to its variable, that is the same content):
<xsl:variable name="filtered-data" select="$data[$filter-column = $filter-identifier]"/>

Does not work, because it comes up with this:

Where the last number, should be 2.

Can any body help me with this?
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic