This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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@spearreport.com] 
Sent: Wednesday, August 21, 2002 2:39 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] 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@ps.ge.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Wednesday, August 21, 2002 5:03 PM
Subject: RE: [xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]