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

re: recursive looping and variable scope

Subject: re: recursive looping and variable scope
From: Brian Newman <brian.newman@xxxxxxxxxxx>
Date: Wed, 6 Jan 2010 19:07:38 -0500
 re: recursive looping and variable scope
I'm afraid I provided the wrong xsl when I first asked this question.  Stress
makes me careless.  I apologize for that.

The code I meant to show is below
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:include href="link1.xsl"/>
	<xsl:include href="link2.xsl"/>
	<xsl:include href="link3.xsl"/>
	<xsl:template match="/">
	<xsl:call-template name="Chain"/>
	</xsl:template>
	<xsl:template name="Chain">
		<xsl:variable name="link1">
			<xsl:call-template name="getSchedule"/>
		</xsl:variable>
		<xsl:variable name="link2">
			<xsl:apply-templates mode="link2" select="$link1/jobs/job"/>
		</xsl:variable>
		<xsl:variable name="link3">
			<xsl:apply-templates mode="link3" select="$link2/policies"/>
		</xsl:variable>
		<xsl:variable name="filename">policy_<xsl:value-of
select="$link1/jobs/job/@jobid"/><xsl:text>.xml</xsl:text></xsl:variable>
		<xsl:result-document href="{$filename}">
				<xsl:copy-of select="$link3/node()"/>
		</xsl:result-document>
		<xsl:call-template name="Chain"/>
	</xsl:template>
	<xsl:template match="node()"/>
</xsl:stylesheet>

As I mentioned earlier, I'm getting an error indicating that I can't write
multiple files to the same URI.  I'm using Saxon and have all my document()
calls wrapped in saxon:discard-document.
$filename doesn't appear to be resetting it's value when I loop.  I'm not sure
why.
Another question, is it generally a good idea to loop like this in Saxon?  I
assume Saxon will release its resources when they go out of scope - especially
with the saxon:discard-document function, but this loop is designed to run an
indeterminate period of time - theoretically forever.

Again, I appreciate the help you've all offered in helping a guy get up to
speed on Saxon and XSLT2.
Hopefully, I can, one day, return the favor by helping someone else out.

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.