[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Given the XML:
And XSLT of:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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:
However, when I don't pass anything in and let the default parameter take over, I get this output:
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:
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
[xsl] Strange Parameter Behavior
Subject: [xsl] Strange Parameter Behavior From: "Michael Peet" <mjpeet@xxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Calculating a sum of roun, Michael Kay | Thread | Re: [xsl] Strange Parameter Behavio, Greg Faron |
[xsl] Calculating a sum of rounded , Nik Krimm | Date | [xsl] Dealing with footnotes, Scott Meadows |
Month |
Keywords