#40 Too many nested apply templates

closed
nobody
None
5
2015-01-19
2005-12-14
No

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&lt;span&gt;[contains(.,'R[') or contains(.,'Service klzzwxh:0025Function Requirements') or contains(.,'Application klzzwxh:0026Software Requirements')]&lt;/span&gt;&lt;span&gt;[1]&lt;/span&gt;"/>
</artefact>
</root>
</xsl:template>

<xsl:template match="text">
<xsl:if test="not(contains(.,$SSDD_START))">
<xsl:if test="starts-with(.,'R&lt;span&gt;[') and klzzwxh:0052substring(.,string-length(.),1)=$REQ_STOP" &gt;klzzwxh:0053="" klzzwxh:0042klzzwxh:0054="" klzzwxh:0043klzzwxh:0055="" klzzwxh:0044klzzwxh:0056="" klzzwxh:0045klzzwxh:0057="" klzzwxh:0046klzzwxh:0058="" klzzwxh:0047klzzwxh:0059="" klzzwxh:0048klzzwxh:0060="" klzzwxh:0049klzzwxh:0061="" klzzwxh:0050klzzwxh:0062="" klzzwxh:0051klzzwxh:0063="" &lt;xsl:apply-templates="" select="following-klzzwxh:0064sibling::text[1]&lt;/span&gt;"/>
</xsl:template>

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

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

</xsl:stylesheet>

Discussion

  • geoffhopkins

    geoffhopkins - 2005-12-14

    xml source

     
  • Nobody/Anonymous

    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

     
  • Nobody/Anonymous

    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

     
  • Michael Kay

    Michael Kay - 2005-12-21

    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...

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks