Q
QTR
Hello,
I discovered a strange XSLT behaviour on Weblo 8.1. Let me explain it
(see at the end my example XSLT):
I call a template (1) with one parameter (A) which calls another
template (2) with two parameters. The first parameter is param A
(obtained from template 1) and the second param comes from another
template (3) which just returns the given param (C).
The second template receives 2 params (A and C) and prints them out.
Thus, in my example I see:
param1: paramA
param2: paramC
So far so good.
The problem comes in when I change the order of the two params when
calling template 2! If I put the line which sets param1 for calling
template 2 *after* param2 then template 2 prints out 2 times the same
thing!
Thus, in my example I'd see:
param1: paramC
param2: paramC
It seems that paramA has been overwritten by paramC!
If I don't call template3 but set param2 (paramC) directly (hardcoded)
in template1 then the order of the passed params doesn't matter. Then
it works fine.
Can somebody explain me this strange behavoiur please?
BTW: I discovered this on Weblogic but on Tomcat and on IIS (MSXML2) it
works without problems!!
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:call-template name="template1">
<xsl:with-param name="paramA">paramA</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="template1">
<xslaram name="paramA"/>
<xsl:call-template name="template2">
<!--the following line works correctly-->
<xsl:with-param name="param1"><xsl:value-of
select="$paramA"/></xsl:with-param>
<xsl:with-param name="param2">
<xsl:call-template name="template3">
<xsl:with-param name="paramC">paramC</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
<!--the following line works incorrectly
<xsl:with-param name="param1"><xsl:value-of
select="$paramA"/></xsl:with-param>
-->
</xsl:call-template>
</xsl:template>
<xsl:template name="template2">
<xslaram name="param1"/>
<xslaram name="param2"/>
param1: <xsl:value-of select="$param1"/><br/>
param2: <xsl:value-of select="$param2"/><br/>
</xsl:template>
<xsl:template name="template3">
<xslaram name="paramC"/>
<xsl:value-of select="$paramC"/>
</xsl:template>
</xsl:stylesheet>
I discovered a strange XSLT behaviour on Weblo 8.1. Let me explain it
(see at the end my example XSLT):
I call a template (1) with one parameter (A) which calls another
template (2) with two parameters. The first parameter is param A
(obtained from template 1) and the second param comes from another
template (3) which just returns the given param (C).
The second template receives 2 params (A and C) and prints them out.
Thus, in my example I see:
param1: paramA
param2: paramC
So far so good.
The problem comes in when I change the order of the two params when
calling template 2! If I put the line which sets param1 for calling
template 2 *after* param2 then template 2 prints out 2 times the same
thing!
Thus, in my example I'd see:
param1: paramC
param2: paramC
It seems that paramA has been overwritten by paramC!
If I don't call template3 but set param2 (paramC) directly (hardcoded)
in template1 then the order of the passed params doesn't matter. Then
it works fine.
Can somebody explain me this strange behavoiur please?
BTW: I discovered this on Weblogic but on Tomcat and on IIS (MSXML2) it
works without problems!!
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:call-template name="template1">
<xsl:with-param name="paramA">paramA</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="template1">
<xslaram name="paramA"/>
<xsl:call-template name="template2">
<!--the following line works correctly-->
<xsl:with-param name="param1"><xsl:value-of
select="$paramA"/></xsl:with-param>
<xsl:with-param name="param2">
<xsl:call-template name="template3">
<xsl:with-param name="paramC">paramC</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
<!--the following line works incorrectly
<xsl:with-param name="param1"><xsl:value-of
select="$paramA"/></xsl:with-param>
-->
</xsl:call-template>
</xsl:template>
<xsl:template name="template2">
<xslaram name="param1"/>
<xslaram name="param2"/>
param1: <xsl:value-of select="$param1"/><br/>
param2: <xsl:value-of select="$param2"/><br/>
</xsl:template>
<xsl:template name="template3">
<xslaram name="paramC"/>
<xsl:value-of select="$paramC"/>
</xsl:template>
</xsl:stylesheet>