Re: [xsl] Nested apply-templates calls run out of stack space - alternative xslt

Subject: Re: [xsl] Nested apply-templates calls run out of stack space - alternative xslt
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Mon, 19 Dec 2005 17:38:31 +0100
I don't have time for a full length answer, but I recently worked around this limitation by using smart statements that locate the start and end position of the child elements that should be nested and pass that as a list to the template that wraps them.

I must mention that I was wrapping the elements on basis of a level attribute that contained a number value that signified more or less the nesting depth that it was aimed for. From each 'level' I used a sort of quick search to locate the minimum level among all children and used that to retrieve the start/end positions..


geoff hopkins wrote:

XSLT 1.0

The XSLT below fails as there are too many lines
between the start and the stop (6000 lines in one of
my input docs)....
Nested apply-templates calls run out of stack space.

I have tried work arounds to no avial.... if anyone
has any insite into creating a new stylesheet that
does not run out of stack space I would be

Mr Kay suggested the following but this is beyond my
personal XSLT knowledge

Define a key for each of the elements that's the
generate-id() of the most
recent preceding sibling that matches "Point A" or
"Point B". Then do
Muenchian grouping using this key.

the basic premise is that between point SSDD_START and
point SSDD_STOP need to extract information that has
R[xxx] in the data....

SSDD_START and SSDD_STOP can occur once of many times
in the document

xml in
	<text>Application Software Requirements</text>
	<text>Service Function Requirements</text>
	<text>Application Software Requirements</text>
	<text>Service Function Requirements</text>
xml out - I understand this is not what the xslt is
doing but if you can get to this stage I can work out
the rest.


original xslt
<xsl:stylesheet version="1.0"
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="SSDD_START">Application Software
<xsl:variable name="SSDD_STOP">Service Function
<xsl:variable name="REQ_START">R[</xsl:variable>
<xsl:variable name="REQ_STOP">]</xsl:variable>

<xsl:param name="DOC_REF"/>

<xsl:template match="pdf2xml">
		<artefact doc_ref="{$DOC_REF}" doc_type="1">
			<xsl:apply-templates select="text[1]"/>

<xsl:template match="text">
	<xsl:if test="not(contains(.,$SSDD_START))">
		<xsl:if test="starts-with(.,'R[') and
		<instance type_id="1">
			<xsl:attribute name="doc">
				<xsl:value-of select="$DOC_REF"/>
			<xsl:attribute name="sec">
				<xsl:value-of select="."/>

<xsl:template match="text[contains(.,'Service Function

<xsl:template match="text[1]">


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

-- Drs. G.P.H. Josten Consultant

Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199

De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.

Current Thread