xsl-list
[Top] [All Lists]

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

2005-12-19 09:38:31
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..

HTH,
Geert

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)....
[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
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
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
www.daidalos.nl


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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>