Re: [xsl] trying to set a parameter equal to an elements attribute

Subject: Re: [xsl] trying to set a parameter equal to an elements attribute
From: "Noel Golding" <noel@xxxxxxxxxxxxxxx>
Date: Thu, 22 Aug 2002 08:33:34 -0400
Thanks this worked!! 

----- Original Message ----- 
From: "Dion Houston" <dionh@xxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, August 21, 2002 5:55 PM
Subject: RE: [xsl] 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@xxxxxxxxxxxxxxx] 
> Sent: Wednesday, August 21, 2002 2:39 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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@xxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> 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


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


Current Thread