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 September 11th, 2006, 10:26 AM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing variables in match templates

Hi,

I hope you can help. This example should hopefully explain my problem.

I have an XML document (the default document) that contains a list of XML files and an XPath expression in an attribute for each one. Each file is loaded by the match="/" template in a for-each loop using the document function to load the XML into a variable.

I then call <apply-templates select="fileDoc" mode="copy"/>

This copies each file (and does some filtering but I'm not concerned about that in this example). However, I need to reference the XPath of the file that I've stored in a variable in the main for-each loop but isn't accessible from the
Code:
<xsl:template match="*" mode="copy">
or
Code:
<xsl:template match="@*" mode="copy">
templates as I can't pass paramters.

I'm using Saxon so have access to XSLT / XPath 2.0 functionality. I have tried to use saxon:assign but failed totally to get it to work as the
Code:
saxon:expression()
function fails to look up the variable saying
Code:
"Variable $msgCtx has not been declared"
Also, this simple xsl
Code:
<xsl:variable name="myXPath" select="'/'"/>
<xsl:variable name="result" select="saxon:expression($myXPath)"/>
<xsl:message>Result = <xsl:copy-of select="$result"/></xsl:message>
produces
Code:
Result = net.sf.saxon.functions.Evaluate$PreparedExpression@179f36b
as output!?

Can anyone help?

Thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
two different templates for same match attr? gabster XSLT 3 September 6th, 2007 10:56 AM
Changing php variables using the href tag Rayne84 PHP How-To 11 July 12th, 2007 02:47 PM
accessing variables in templates austinf XSLT 1 May 4th, 2006 03:16 AM
changing the value of variables in PHP jflores1 PHP How-To 1 January 8th, 2006 12:09 AM
Elements that don't match any templates clareE XSLT 3 December 21st, 2005 06:20 AM





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