This is very helpful, and may solve my problem. I had no idea you could use the redirect capabilities to shift documents. I have a couple of questions based on this.
I don't see the '$params' declared anywhere. I assume that's just the URI for the parameters document? Would it be possible to put the params document root into a variable, and then reference its contents anywhere in the rest of the XSLT? Thanks very much for the excellent tip. Cory -----Original Message----- From: Foxy Shadis [mailto:foxyshadis@;hotmail.com] Sent: Tuesday, October 29, 2002 12:01 AM To: [EMAIL PROTECTED] Subject: Re: Resuing a DTM I've found that if you chain several transformations together in the same stylesheet, via looping or hardcoding, you can vastly cut down on total running time and memory usage. To loop it, I place all of the parameters in an xml file like this: <list> <entry> <file>title.html</file> <name>Title</name> <param name="prime" select="biglist"/> </entry> <entry> <file>pub.html</file> <name>Publisher</name> <param name="prime" select="publisherlist"/> </entry> </list> And a stylesheet like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:redirect="org.apache.xalan.lib.Redirect" xmlns:xalan="http://xml.apache.org/xalan" extension-element-prefixes="redirect" exclude-result-prefixes="redirect"> <xsl:template match="/"> <xsl:variable name="root" select="/"/> <!-- so that you can move the context back to the xml document when it's in the parameter doc --> <xsl:for-each select="document($params)/list/entry"> <xsl:variable name="file" select="file"/> <xsl:variable name="fname" select="name"/> <xsl:variable name="prime" select="param[@name='prime']/@select[1]"/> <xsl:for-each select="$root"> <!-- move context back --> <redirect:write file="{$file}"> <xsl:call-template name="list"> <xsl:with-param name="prime" select="$prime"/> <xsl:with-param name="called" select="$fname"/> </xsl:call-template> </redirect:write> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> Obviously this is an extremely simplified version, but it shows the point. Note that this method allows you to easily construct an index file by putting the information from each set of parameters before the redirect block, which would be output to the -out file. (You could of course replace the template call in the redirect block with the actual template, but that's pretty messy.) I'm sure there's a better way to select each variable without resorting to document order, but that gets the job done. XSLTC is nice, but I use xalan:evaluate extensively so I'm rather out of luck when it comes to that. ^^ Swiftpaw Foxyshadis, wildlife artist [EMAIL PROTECTED] | http://foxyshadis.slightlydark.com/ >From: "Cory Isaacson" <[EMAIL PROTECTED]> >I have a situation with the following: > >A non-changing XML document >A non-changing XSLT doc >Changing XSLT parameters > >We need to perform multiple repeated transformations based on the variable >parameters (which cause different sections of the XML to be >processed/filtered based on the values). It takes a lot of memory for each >run right now (300K), as the DTM is being recreated each time. Is there any >way I can cache and re-use this, so that its not rebuilding it? > >We have some JSP pages which might call the XSLT 3 or 4 times, so this is >much too large, but with so much of our source being static, I am >interested >in any possible optimizations. > >Thanks, > >Cory _________________________________________________________________ Surf the Web without missing calls! Get MSN Broadband. http://resourcecenter.msn.com/access/plans/freeactivation.asp
