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

RE: trying to set a parameter equal to an elements att

Subject: RE: trying to set a parameter equal to an elements attribute
From: "Dion Houston" <dionh@xxxxxxxxxxxxx>
Date: Wed, 21 Aug 2002 14:55:27 -0700
att nodes houston
Well, actually there are even more issues with the example:

	<header volume="8"/>

	<xsl:param name="vol">
		<xsl:value-of select="header[@volume]"/>
	</xsl:param>

OK, first of all in a simple case like this, you probably don't want an
RTF, although it'd work...  So the first step is to add a select:

	<xsl:param name="vol" select="header[@volume]"/>

The second issue is in the XPath... note that the end result of the
above XPath is a _header_ node (header[@volume] means all header nodes
which have a volume attribute), not the volume attribute.  Therefore,
when you use it as a number, it's going to take the text content of the
header element, which is empty.

What you probably intend is:

	<xsl:param name="vol" select="header/@volume"/>

In this case, you're going to assign the volume attribute to the
variable.  As a matter of preference, since you're using this as a
numeric value, I'd go ahead and case it:

	<xsl:param name="vol" select="number(header/@volume)"/>

Because of the semantics of nodesets in different places, this can
sometimes keep you out of trouble.

HTH!

Dion

-----Original Message-----
From: Noel Golding [mailto:noel@xxxxxxxxxxxxxxx] 
Sent: Wednesday, August 21, 2002 2:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  trying to set a parameter equal to an elements
attribute

even with the namespace it still does not retrieve the value.

----- Original Message ----- 
From: <sara.mitchell@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, August 21, 2002 5:03 PM
Subject: RE:  trying to set a parameter equal to an elements
attribute


> Well, every XSLT engine that I'm familiar with requires 
> a valid namespace for XSLT in the stylesheet element. So 
> 
> 
> > <xsl:stylesheet version="1.0" xmlns:xsl="">
> 
> should be 
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> Sara
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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


 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.