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

Subject: [xsl] Nested apply-templates calls run out of stack space - alternative xslt
From: geoff hopkins <geoffhopkins123@xxxxxxxxx>
Date: Mon, 19 Dec 2005 06:59:55 -0800 (PST)
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)....
[error]
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
appreciative....

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
<root>
	<text></text>
	<text>R[1]</text>
	<text>R[2]</text>
	<text>Application Software Requirements</text>
	<text>R[3]</text>
	<text>R[4]</text>
	<text>Service Function Requirements</text>
	<text>R[5]</text>
	<text>Application Software Requirements</text>
	<text>R[6]</text>
	<text>Service Function Requirements</text>
	<text>R[7]</text>
</root>
===
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.

<root>
	<text>R[3]</text>
	<text>R[4]</text>
	<text>R[6]</text>
</root>

===
original xslt
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="SSDD_START">Application Software
Requirements</xsl:variable>
<xsl:variable name="SSDD_STOP">Service Function
Requirements</xsl:variable>
<xsl:variable name="REQ_START">R[</xsl:variable>
<xsl:variable name="REQ_STOP">]</xsl:variable>

<xsl:param name="DOC_REF"/>

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

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

<xsl:template match="text[contains(.,'Service Function
Requirements')]">
	<xsl:apply-templates
select="following-sibling::text[contains(.,$SSDD_START)][1]"/>
</xsl:template>

<xsl:template match="text[1]">
	<xsl:apply-templates
select="following-sibling::text[contains(.,$SSDD_START)][1]"/>
</xsl:template>

</xsl:stylesheet>



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread