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

Cascading Attributes?

Subject: Cascading Attributes?
From: William Bagby <williamb@xxxxxxxxx>
Date: Fri, 25 May 2001 11:50:01 -0400
what is a cascading attribute
I have an XML element <text> with an optional attribute @class.  In the
template matching this element, I'd like to have a variable $class which
takes one of the following values, with lower number taking precedence:

1. a param called class passed to the template using <with-param>
2. optional attribute @class if it is defined
3. the string "none"

In other words, if my XSL is:

<xsl:apply-templates select="text"/>

I want $class to be text/@class if it is defined, otherwise "none".  But if
my XSL is:

<xsl:variable name="myvar">myclass</xsl:variable>
<xsl:apply-templates select="text">
	<xsl:with-param name="myvar"/>

I want $class to be "myclass", regardless of whether or not @class is

I tried the following:

<xsl:template match="text">
	<xsl:param name="class">
			<xsl:when test="@class"><xsl:value-of
	<a href="{@href}" class="{$class}"><xsl:value-of select="."/></a>

But it doesn't work.  I'm sure I could probably figure it out, but I'm
looking for something elegant, or at least something easy to read.  Maybe
what I really want to know is why my XSL doesn't work, which is really
another way of asking, "How does <xsl:param> work?"

William Bagby.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.