Project

Profile

Help

Support #1343

closed

Too many nested apply templates

Added by Anonymous almost 19 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Internals
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Legacy ID:
sf-1380609
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

SourceForge user: geoffhopkins

Error will become apparent when running XSLT with XML

source... if one line is removed the

program works ok... Can't provide the true source for

confidentiality reasons,,, the true source is actually

7000 lines between point A and B.

<xsl:stylesheet version="2.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[contains(.,'R[') or contains(.,'Service

Function Requirements') or contains(.,'Application

Software Requirements')][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>


Files

input.xml (9.56 KB) input.xml Anonymous, 2005-12-14 18:02
Actions #1

Updated by Anonymous almost 19 years ago

SourceForge user: nobody

Logged In: NO

Thanks. Although this example runs to completion, it's clear

in the debugger that it's comsuming stack space - which

means the tail recursion optimization isn't kicking in for

this stylesheet for some reason; there should be enough here

to find out why.

Michael Kay

Actions #2

Updated by Anonymous almost 19 years ago

SourceForge user: nobody

Logged In: NO

I think I've fixed this: tail call optimization for

apply-templates was only working for one level of calls,

whereas in this example there is a tail-recursive template

that invokes another tail-recursive template.

Michael Kay

Actions #3

Updated by Anonymous almost 19 years ago

SourceForge user: mhkay

Logged In: YES

user_id=251681

Unfortunately my fix has side-effects: the delayed

evaluation of the recursively called template is happening

after the context has been changed. So it's back to the

drawing board. Function calls, which don't depend on the

context, are so much easier to manage...

Please register to edit this issue

Also available in: Atom PDF