RE: [xsl] Problem with identity transform and Saxon

Subject: RE: [xsl] Problem with identity transform and Saxon
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 7 Aug 2005 21:19:50 +0100
The result of exslt-common:node-set() is a document node, therefore in

        <xsl:template match="/">
                <xsl:apply-templates select="exsl-common:node-set($rtf)" />
        </xsl:template>

the apply-templates call will invoke this same template rule, causing
infinite recursion.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Kenneth Stephen [mailto:marvin.the.cynical.robot@xxxxxxxxx] 
> Sent: 06 August 2005 16:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Problem with identity transform and Saxon
> 
> Hi,
> 
>     I have the following code :
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>         xmlns:exsl-common="http://exslt.org/common";
>         version="1.0">
> 
>         <xsl:variable name="rtf" xml:space="preserve">
>                 <a>
>                         <b />
>                 </a>
>         </xsl:variable>
> 
>         <xsl:template match="/">
>                 <xsl:apply-templates 
> select="exsl-common:node-set($rtf)" />
>         </xsl:template>
> 
>         <xsl:template match="@*|node()">
>                 <xsl:copy>
>                         <xsl:apply-templates select="@*|node()" />
>                 </xsl:copy>
>         </xsl:template>
> 
> </xsl:stylesheet>
> 
> java net.sf.saxon.Transform <XSL filename> <XSL filename>
> 
> produces the following :
> 
> Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
> java.lang.StackOverflowError
>         at java.lang.Object.getClass(Native Method)
>         at 
> net.sf.saxon.value.SingletonNode.convertToJava(SingletonNode.java:192)
>         at 
> net.sf.saxon.functions.ExtensionFunctionCall.setupParams(Exten
> sionFunctionCall.ja
> va:330)
>         at 
> net.sf.saxon.functions.ExtensionFunctionCall.call(ExtensionFun
> ctionCall.java:211)
>         at 
> net.sf.saxon.functions.ExtensionFunctionCall.iterate(Extension
> FunctionCall.java:1
> 11)
>         at net.sf.saxon.expr.ItemChecker.iterate(ItemChecker.java:83)
>         at net.sf.saxon.value.Closure.iterate(Closure.java:201)
>         at net.sf.saxon.value.Value.getIterator(Value.java:202)
>         at 
> net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.pro
cessLeavingTail(App
> lyTemplates.java:431)
>         at 
> net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTempl
> ates.java:276)
>         at 
> net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.pro
cessLeavingTail(App
> lyTemplates.java:431)
> .
> .
> .
> .
>         at 
> net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTempl
> ates.java:276)
> Exception in thread "main" 
> 
>     This is with Saxon 8.4. Any ideas on what I'm doing wrong?
> 
> Thanks,
> Kenneth

Current Thread