This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Using a parameter to represent an attribute
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 16 Aug 2002 22:37:01 -0700 (PDT)
- Subject: [xsl] Re: Using a parameter to represent an attribute
- Reply-to: xsl-list at lists dot mulberrytech dot com
--- Kathryn dot Grant at freight dot fedex dot com wrote:
> Hi all,
>
> I'm stuck. I'm sure this is very simple, but I've been searching my
> XSL
> books and the web and can't find an answer.
>
> Here's my original XSL, in which I select and sort based on the S3G
> attribute of the <record>.
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>
> <xsl:output method="html"/>
>
> <xsl:template match="/">
> <TABLE border="1" width="90%" style="font-size:10pt" cellpadding="0"
> cellspacing="0">
> <tr valign="top">
> <th width="16%"><b>Field Name</b></th>
> <th width="42%"><b>Description</b></th>
> <th width="42%"><b>Entry Detail</b></th>
> </tr>
> <xsl:for-each select="//brpfields/record[@S3G >'0']">
> <xsl:sort data-type="number" select="@S3G"/>
> etc. etc.
>
>
>
> I want to use a parameter in place of S3G (Ultimately I'll be passing
> the
> value from an external javascript). So I tried this:
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
> <xsl:param name="param1" select="S3G"/>
>
> <xsl:output method="html"/>
>
> <xsl:template match="/">
> <TABLE border="1" width="90%" style="font-size:10pt" cellpadding="0"
> cellspacing="0">
> <tr valign="top">
> <th width="16%"><b>Field Name</b></th>
> <th width="42%"><b>Description</b></th>
> <th width="42%"><b>Entry Detail</b></th>
> </tr>
> <xsl:for-each select="//brpfields/record[@$param1 >'0']">
> <xsl:sort data-type="number" select="@$param1"/>
>
> But the transformation chokes on the $. I've tried various
> permutations of
> quotes; I've tried braces; I've tried everything I can think of. Why
> doesn't it like the parameter for the <record> attribute value?
Hi Kathryn,
Use:
<xsl:for-each select="//brpfields/record[@*[name()=$param1] >'0']">
<xsl:sort data-type="number" select="@*[name()=$param1]"/>
..........
</xsl:for-each>
I find the following a little bit simpler:
<xsl:for-each select="//brpfields/record/@*[name()=$param1][. >'0']">
<xsl:sort data-type="number" select="."/>
..........
</xsl:for-each>
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list