[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Capturing result of <xsl:apply-templates/> in a v

Subject: Re: Capturing result of <xsl:apply-templates/> in a variable
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 06 Dec 2011 20:08:04 +0000
Re:  Capturing result of <xsl:apply-templates/> in a  v
This was probably the first time in my years of working with XSLT that it occurred to me to capture <xsl:apply-templates/> in a variable (I'll never be an XSLT wizard). I'm wondering: is the procedure above guaranteed to work in all cases, or is it possible that the <xsl:copy-of select="$appliedTemplates"/> could ever return something different from <xsl:apply-templates/> in this context?
Doing xsl:copy-of on the variable is perfectly safe. Doing apply-templates or other processing on it can be risky - because the copied nodes differ from the original by having fewer ancestors, so logic that looks outside the immediate subtree will behave differently.

On a related point, people often use xsl:message to produce diagnostic output. I often find it more helpful to put the diagnostic data in the result document itself, so you'll see me writing stuff like

<xsl:variable name="v" select="....."/>
<debug var="$v">
<xsl:copy-of select="$v"/>
</debug>

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.