Hi everybody, first post ... please be patient.
I am having trouble using the "redirect" extension element on my own style sheets. I did the sample 1-redir.xml which worked fine, but I get a StackOverflow error when transforming a document of my own (both stylesheet and sample document are attached at the end of this post). As you can see the stylesheet is moderately recursive, but not at all at this point. So the StackOverflowError must have its cause somewhere else. thanks in advance for any help, and Happy New Year! cheers, Jakob. ---------------8<---------------8<--------------- G:\>java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -param toctype toc -param out.path foodir file:///G:/test.xsl; Ligne #84; Colonne #38; Erreur XSLT (javax.xml.transform.TransformerException): java.lang.StackOverflowError Line 84 corresponds to the line which contains the <redirect:write> start tag. ---------------8<---------------8<--------------- I am using the latest version of Xalan-J, and JRE 1.4.1 G:\>java org.apache.xalan.xslt.Process -v >>>>>>> Version de Xalan Xalan Java 2.5.2, <<<<<<< G:\>java -version java version "1.4.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01) Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode) ---------------8<---------------8<--------------- the stylesheet: <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dy="http://www.dynaprism.org/dy/1.0" xmlns:redirect="http://xml.apache.org/xalan/redirect" extension-element-prefixes="redirect"> <xsl:strip-space elements=" IMOCODE BLOCK ART REG PART SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 INSUB1 INSUB2 INSUB3 INSUB4 INSUB5 INSUB6 FNOTE TAB FIG "/> <!-- ********************************************* --> <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/> <!-- ********************************************* --> <xsl:param name="toctype"/><!-- one of "toc, "lof" or "lot" --> <xsl:param name="out.path"/> <!-- ********************************************* --> <xsl:key name="node.children" match="//[EMAIL PROTECTED]" use="@AN"/> <!-- ********************************************* --> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <!-- ********************************************* --> <xsl:template match="[EMAIL PROTECTED]"> <xsl:variable name="child.nodes" select="key('node.children', @ID)"/> <xsl:choose> <!-- if the current node has children, i.e. if there are other nodes in the documents with AN attributes containing this node's ID value --> <xsl:when test="count($child.nodes) > 0"> <xsl:call-template name="tpl.write.fragment"> <xsl:with-param name="child.nodes" select="$child.nodes"/> </xsl:call-template> </xsl:when> <!-- otherwise, we don't do anything --> <xsl:otherwise/> </xsl:choose> </xsl:template> <!-- ********************************************* --> <xsl:template name="tpl.write.fragment"> <!-- first, get all direct children of the current node --> <xsl:param name="child.nodes"/> <xsl:variable name="out.file" select="concat($out.path, '/', $toctype, '/', @ID, '.xml')"/> <!-- now write the fragment --> <redirect:write select="$out.file"> <dy:toc gi="[EMAIL PROTECTED]" id="[EMAIL PROTECTED]" toc="{$toctype}"> <xsl:for-each select="$child.nodes"> <xsl:element name="dy:tocitem"> <xsl:attribute name="id"><xsl:call-template name="tpl.get.idwithpipe.v2"/></xsl:attribute> <xsl:attribute name="gi"><xsl:value-of select="@GI"/></xsl:attribute> <xsl:attribute name="leaf"><xsl:choose><xsl:when test="key('node.children', @ID)">0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:attribute> <xsl:attribute name="depth"><xsl:value-of select="(string-length(@ID)-1) div 4"/></xsl:attribute> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </dy:toc> </redirect:write> </xsl:template> <!-- ********************************************* --> <xsl:template name="tpl.get.idwithpipe.v2"> <!-- contains pipe's position, beginning from end of string, default 0, i.e. no pipe --> <xsl:param name="current.length" select="0"/> <!-- --> <xsl:param name="original.id" select="@ID"/> <!-- --> <xsl:param name="current.node" select="."/> <!-- --> <xsl:variable name="current.previous.node" select="preceding-sibling::*[1]"/> <xsl:choose> <!-- previous ID length greater or equal than current ID length, or doesn't have a preceding sibling (root node) - normal case --> <xsl:when test="string-length($original.id) >= string-length($current.previous.node/@ID) or not($current.previous.node)"> <xsl:choose> <xsl:when test="$current.length > 0"> <xsl:value-of select="concat( substring($original.id, 1, string-length($original.id) - $current.length), '|', substring($original.id, string-length($original.id) - $current.length + 1) )"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="@ID"/> </xsl:otherwise> </xsl:choose> </xsl:when> <!-- previous ID length is lesser than current ID length - case when a fragment is first child --> <xsl:otherwise> <xsl:call-template name="tpl.get.idwithpipe.v2"> <xsl:with-param name="original.id" select="$original.id"/> <xsl:with-param name="current.node" select="$current.previous.node"/> <xsl:with-param name="current.length" select="$current.length + 4"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> ---------------8<---------------8<--------------- the document <?xml version="1.0" encoding="iso-8859-1"?> <dy:nodes xmlns:dy="http://www.dynaprism.org/dy/1.0"> <dy:node GI="IMOCODE" ID="n0001">The International Code for Fire Safety Systems (FSS Code)</dy:node> <dy:node GI="BLOCK" ID="n00010002" AN="n0001">Bureau Veritas Foreword</dy:node> <dy:node GI="BLOCK" ID="n00010003" AN="n0001">Preamble</dy:node> <dy:node GI="SUB1" ID="n000100030002" AN="n00010003">1 - The purpose of this Code is to ...</dy:node> <dy:node GI="SUB1" ID="n000100030003" AN="n00010003">2 - On or after 1 July 2002, this ...</dy:node> <dy:node GI="CHAP" ID="n00010004" AN="n0001">Chapter 1 - General</dy:node> <dy:node GI="SUB1" ID="n000100040002" AN="n00010004">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100040003" AN="n00010004">2 - Definitions</dy:node> <dy:node GI="SUB1" ID="n000100040004" AN="n00010004">3 - Use of equivalents and modern technology</dy:node> <dy:node GI="SUB1" ID="n000100040005" AN="n00010004">4 - Use of toxic extinguishing media</dy:node> <dy:node GI="CHAP" ID="n00010005" AN="n0001">Chapter 2 - International shore connections</dy:node> <dy:node GI="SUB1" ID="n000100050002" AN="n00010005">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100050003" AN="n00010005">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010006" AN="n0001">Chapter 3 - Personnel protection</dy:node> <dy:node GI="SUB1" ID="n000100060002" AN="n00010006">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100060003" AN="n00010006">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010007" AN="n0001">Chapter 4 - Fire extinguishers</dy:node> <dy:node GI="SUB1" ID="n000100070002" AN="n00010007">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100070003" AN="n00010007">2 - Type approval</dy:node> <dy:node GI="SUB1" ID="n000100070004" AN="n00010007">3 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010008" AN="n0001">Chapter 5 - Fixed gas fire-extinguishing systems</dy:node> <dy:node GI="SUB1" ID="n000100080002" AN="n00010008">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100080003" AN="n00010008">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010009" AN="n0001">Chapter 6 - Fixed foam fire-extinguishing systems</dy:node> <dy:node GI="SUB1" ID="n000100090002" AN="n00010009">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100090003" AN="n00010009">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010010" AN="n0001">Chapter 7 - Fixed pressure water-spraying and water-mist fire-extinguishing systems</dy:node> <dy:node GI="SUB1" ID="n000100100002" AN="n00010010">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100100003" AN="n00010010">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010011" AN="n0001">Chapter 8 - Automatic sprinkler, fire detection and fire alarm systems</dy:node> <dy:node GI="SUB1" ID="n000100110002" AN="n00010011">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100110003" AN="n00010011">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010012" AN="n0001">Chapter 9 - Fixed fire detection and fire alarm systems</dy:node> <dy:node GI="SUB1" ID="n000100120002" AN="n00010012">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100120003" AN="n00010012">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010013" AN="n0001">Chapter 10 - Sample extraction smoke detection systems</dy:node> <dy:node GI="SUB1" ID="n000100130002" AN="n00010013">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100130003" AN="n00010013">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010014" AN="n0001">Chapter 11 - Low-location lighting systems</dy:node> <dy:node GI="SUB1" ID="n000100140002" AN="n00010014">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100140003" AN="n00010014">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010015" AN="n0001">Chapter 12 - Fixed emergency fire pumps</dy:node> <dy:node GI="SUB1" ID="n000100150002" AN="n00010015">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100150003" AN="n00010015">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010016" AN="n0001">Chapter 13 - Arrangement of means of escape</dy:node> <dy:node GI="SUB1" ID="n000100160002" AN="n00010016">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100160003" AN="n00010016">2 - Passenger ships</dy:node> <dy:node GI="SUB1" ID="n000100160004" AN="n00010016">3 - Cargo ships</dy:node> <dy:node GI="CHAP" ID="n00010017" AN="n0001">Chapter 14 - Fixed deck foam systems</dy:node> <dy:node GI="SUB1" ID="n000100170002" AN="n00010017">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100170003" AN="n00010017">2 - Engineering specifications</dy:node> <dy:node GI="CHAP" ID="n00010018" AN="n0001">Chapter 15 - Inert gas systems</dy:node> <dy:node GI="SUB1" ID="n000100180002" AN="n00010018">1 - Application</dy:node> <dy:node GI="SUB1" ID="n000100180003" AN="n00010018">2 - Engineering specifications</dy:node> </dy:nodes> ---------------8<---------------8<--------------- [sorry for unconventional linebreaks.]