469,927 Members | 1,399 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

XSLT Parameter scoping problem using .Net and XSLTArgumentList

I am having a problem with scoping of parameters in my XSLT
Stylesheet...here is the stylesheet (the xml document is irrelevant
for the example)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="myParam">Stylesheet Default</xsl:param>
<xsl:template match="/">
<result_explicit_call>
<xsl:call-template name="test">
<xsl:with-param name="myParam">Explicit Call</xsl:with-param>
</xsl:call-template>
</result_explicit_call>

<result_template_default>
<xsl:call-template name="test"/>
</result_template_default>

</xsl:template>

<xsl:template name="test">
<xsl:param name="myParam">Template Default</xsl:param>
<xsl:value-of select="$myParam"/>
</xsl:template>
</xsl:stylesheet>

The 'Correct' result for this transform (what MSXML4 returns) is...
<result_explicit_call>Explicit Call</result_explicit_call>
<result_template_default>Template Default</result_template_default>

However if I do it in .Net Version 1.1.4332 and pass down a new
parameter using xsltargument list ('Passed in'), it blows away all my
local scoping of the parameter...
<result_explicit_call>Passed in</result_explicit_call>
<result_template_default>Passed in</result_template_default>

Is this a known issue?? Is there a workaround??

Any help appreciated.

Michael Dausmann
Nov 11 '05 #1
1 1974
Michael wrote:
I am having a problem with scoping of parameters in my XSLT
Stylesheet...here is the stylesheet (the xml document is irrelevant
for the example)


Seems like a bug. I've simplified stylesheet to this one:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="param"/>
<xsl:template match="/">
<xsl:variable name="param" select="'Shadowing value'"/>
<xsl:value-of select="$param"/>
</xsl:template>
</xsl:stylesheet>

Here local variable "param" in the template must shadow any namesake global
variables and parameters, so the result must be "Shadowing value" anyway.

I've tested it under .NET 1.1. Results are:
1. No parameter value passed into transformation:
"Shadowing value"
2. "Passed in" parameter value passed into transformation:
"Passed in"

That's interesting to note that default parameter value doesn't affect
shadowing - it works as it should, but when passing actual parameter value it
breaks shadowing.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Gauthier | last post: by
1 post views Thread by Sonu Kapoor | last post: by
8 posts views Thread by Eric Phetteplace | last post: by
7 posts views Thread by Harolds | last post: by
1 post views Thread by cameron | last post: by
1 post views Thread by Nick | last post: by
4 posts views Thread by =?Utf-8?B?REZC?= | last post: by
10 posts views Thread by bbembi_de | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.