Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2012, 06:03 AM
Registered User
 
Join Date: Jul 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default XSL Call template with match tag doesn't copy values of passed param.

Hello Everyone,

I am new to XSLT, and tried searching for a solution to this problem over the internet but couldn't get any suitable answer, here's my problem statement:


I am trying to call a "template" with a parameter, which has got a "match" element defined, but it seems that parameter value is not getting copied when the called "template" has got a "match" element defined:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/head">
<xsl:call-template name="getKeys">
<xsl:with-param name="Keys">IndexOne</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="/head/childOne/body" name="getKeys">
<xsl:param name="Keys"/>

<xsl:for-each select="table">

<xsl:if test="$Keys='IndexOne'"> <=== The IF statement is not evaluated
to true with "match" element defined.
Do Some processing ........

</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:template>

The If statement is never evaluated to true as the param "Keys" contains null (""). The code under If statements hits if I remove the "match" element in "getKeys" template tag.

The reason for using "match" element is to avoid multiple occurrences of code under the if statement while iterating through the nodes. Appreciate if anyone can suggest a solution for it. Thanks in advance.
 
Old July 9th, 2012, 07:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you are right, then this would be a bug in your XSLT processor. Try the code with a different XSLT processor just to check.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 30th, 2012, 04:44 AM
Registered User
 
Join Date: Jul 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hello Michael,

Thanks for your suggestion and sorry for delayed response, I figured out another way to overcome this issue by removing match="/head/childOne/body" from <xsl:template> tag and am now providing an absolute path in the <xsl:for select="/head/childOne/body/table"> .... though the parser throws some warnings but it gives the desired output.

Regards,
Suresh V





Similar Threads
Thread Thread Starter Forum Replies Last Post
Param in template match=" " iceandrews XSLT 2 May 7th, 2008 07:37 AM
Is this possible <call-template name="$param"/>? rushman XSLT 2 April 12th, 2007 01:04 PM
xsl:template match 'overlapping' ? Kabe XSLT 1 February 25th, 2005 06:03 AM
import / call / template match Kabe XSLT 3 February 26th, 2004 11:31 AM
help with xsl template match enT XSLT 9 September 24th, 2003 06:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.