Subject: Re: [xsl] 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) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] trying to set a parameter, Noel Golding | Thread | Re: [xsl] trying to set a parameter, Noel Golding |
RE: [xsl] trying to set a parameter, sara . mitchell | Date | Re: [xsl] trying to set a parameter, Noel Golding |
Month |