Subject: Re: [xsl] Strange Parameter Behavior From: "Michael Peet" <mjpeet@xxxxxxxxxxx> Date: Fri, 10 May 2002 09:02:21 -0400 |
param-id: 3 prev: 6 next: 4
<c id="3"/> <c id="8"/> <c id="12"/>
<c id="6"/> <c id="10"/>
<xsl:param name="param-id" select="(/a/b/c)[1]/@id"/> <xsl:param name="param-id" select="/a[1]/b[1]/c[1]/@id"/>
From: "Michael Peet" <mjpeet@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Strange Parameter Behavior Date: Thu, 09 May 2002 17:01:41 -0400
Given the XML:
<a id="1"> <b id="2"> <c id="3"/> <c id="4"/> <c id="5"/> <c id="6"/> </b> <b id="7"> <c id="8"/> <c id="9"/> <c id="10"/> </b> <b id="11"> <c id="12"/> <c id="13"/> <c id="14"/> </b> </a>
And XSLT of:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="ascii" omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:param name="param-id" select="/a/b/c[1]/@id"/>
<xsl:template match="/"> param-id: <xsl:value-of select="$param-id"/><br/> prev: <xsl:value-of select="//c[@id = $param-id]/preceding::c[1]/@id"/><br/> next: <xsl:value-of select="//c[@id = $param-id]/following::c[1]/@id"/><br/> </xsl:template>
</xsl:stylesheet>
I get the following expected results when passing in a parameter:
param-id: 12 prev: 10 next: 13
However, when I don't pass anything in and let the default parameter take over, I get this output:
param-id: 3 prev: 6 next: 4
Could anyone explain this? Is there a RTF at work here? When I wrap the
default parameter value with a string() function, the stylesheet returns the
expected results:
param-id: 3 prev: next: 4
Is that the "correct" solution? More importantly, does anyone know why case
2 produces those results? It evaluates 'next' correctly, but why is 'prev'
so far off?
Thanks in advance!
Mike
_________________________________________________________________ Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
SV: [xsl] Strange Parameter Behavio, bryan | Thread | [xsl] Dealing with footnotes, Scott Meadows |
Re: [xsl] linking transformations, David Carlisle | Date | RE: [xsl] linking transformations, Michael Kay |
Month |