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

Re: Using a parameter to represent an attribute

Subject: Re: Using a parameter to represent an attribute
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 16 Aug 2002 22:37:01 -0700 (PDT)
xslt sort based on parameter
--- 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


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.