Subject: RE: Error: when distance between section definitions exceed 3678 (roughly)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 30 Nov 2005 18:45:52 -0000
|
Your stylesheet makes one call on xsl:apply-templates for each sibling. When
there are 3678 siblings there are going to be 3678 nested apply-templates
calls. Many processors under such conditions will run out of stack space.
Your apply-templates calls are the last thing each template does, so they
are amenable to an optimization technique called tail-call-optimization. I
would have expected Saxon 6.5.x to apply this technique, but it's a long
time ago so I can't be sure. Certainly Saxon 8.x should handle it. However,
if you are determined to use MSXML for a problem that it can't handle, then
I can't help you.
The following tests are wrong:
<xsl:if test=".!=contains(.,$SSDD_START)">
> <xsl:if test=".=starts-with(.,$REQ_START)
You're comparing a singleton node-set to a boolean, which will always be
true. I don't know whether fixing that will help you.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: geoff hopkins [mailto:geoffhopkins123@xxxxxxxxx]
> Sent: 30 November 2005 14:43
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Error: when distance between section
> definitions exceed 3678 (roughly)
>
> The basic premise of the xsl below is to define
> sections that fall between two marker points
> 'Application Software Requirements and 'Service
> Function Requirements' . The problem I have is if
> these two marker points have roughly 3678 (or more)
> other nodes between then
>
> i.e.
>
> 1. <root>
> 2. <text>'Application Software Requirements</text>
> 3. <text></text>
> ..
> ..
> 3685. <text>Service Function Requirements</text>
> 3686. <text></text>
> </root>
>
> I get this error message (MSXML4.0)
> Code: 0x80004005
> The XSL Processor stack has overflowed - probable
> cause is infinite template recursion.
> I get this error message (Saxon 6.5.3)
> An exception of type 'java/lang/StackOverflowError'
> was not handled
>
> Unfortunately I am tied into MSXML for this project,
> any ideas why this is happening? do I need to redefine
> my xsl, if yes will need a good guide as I am quite
> rubbish at it.
>
> Regards,
>
> Geoff
>
> p.s. can't supply the source xml as it contains
> sensitive data.
>
> <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}">
> <xsl:apply-templates select="text[1]"/>
> </artefact>
> </root>
> </xsl:template>
>
> <xsl:template match="text">
> <xsl:if test=".!=contains(.,$SSDD_START)">
> <xsl:if test=".=starts-with(.,$REQ_START) 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>
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
|