[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: Mike Brown <mike@xxxxxxxx>
Date: Wed, 21 Aug 2002 15:22:44 -0600 (MDT)
name xsl value of
Noel Golding wrote:
> > <!-- XML FILE -->
> > <root>
> >     <header volume="8"/>
> >
> >     <article>
> >         <para>
> >             Some text here
> >        </para>
> >     </article>
> > </root>
> >
> > <!-- XSLT FILE -->
> > <xsl:stylesheet version="1.0" xmlns:xsl="">
> >     <xsl:template match="root">
> >         <xsl:param name="vol"><xsl:value-of select="header[@volume]"/>
> >     </xsl:template>
> > </xsl:stylesheet>

1. you need to put the XSLT namespace name in the xmlns:xsl

2. xsl:variable and xsl:param create a new object and give it a name.
   xsl:value-of creates a text node, unless there is no text to create.

Assuming you meant to put </xsl:param> after the value-of, what you did was
try to set $vol to whatever value for it was passed into the template. None
was (unless there's more to your stylesheet), so $vol was instead set to be a
new object of type "result tree fragment" (which is a non-traversable
node-set). This object consisted of a root node with one child: the text node
that was created by xsl:value-of.  You created this 'vol' object but you never
made reference to $vol, so you got no output.

I assume you just wanted

<xsl:template match="root">
  <xsl:value-of select="header[@volume]"/>
</xsl:template>

or

<xsl:template match="root">
  <xsl:variable name="vol" select="header[@volume]"/>
  <xsl:value-of select="$vol"/>
</xsl:template>

or, if you're passing in $vol from outside the stylesheet, but defaulting
it to header[@volume] if it's not passed in, you need a top-level param:

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

<xsl:template match="root">
  <xsl:value-of select="$vol"/>
</xsl:template>

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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.