Quantcast

XTDE1480: Cannot execute xsl:result-document while evaluating variable

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

XTDE1480: Cannot execute xsl:result-document while evaluating variable

Matthieu RICAUD-DUSSARGET-2
Hi all,

We recently moved from saxon EE 9.5.1.5 to saxon EE 9.7.0.13 and we faced this problems
"XTDE1480: Cannot execute xsl:result-document while evaluating variable"

This use to work fine with saxon 9.5, I was wondering if this is rather a saxon bogue or XSLT compliance of our code ?

I could easily give the full example in a zip as private message, but it's giving a simple example is a bit time which I don't have unfortunately.
Nevertheless I can explain what does the XSLT :

There is an XSLT "convert2xhtml.xsl" which is multi-step using this kind of construct :
 
<xsl:template match="/" mode="convert2xhtml">
    <xsl:variable name="step1" as="document-node()">
      <xsl:document>
        <xsl:apply-templates select="." mode="step1"/>
      </xsl:document>
    </xsl:variable>
    <xsl:result-document href="log/step1.log.xml">
      <xsl:sequence select="$step1"/>
    </xsl:result-document>
    <xsl:variable name="step2" as="document-node()">
      <xsl:document>
        <xsl:apply-templates select="$step1" mode="step2"/>
      </xsl:document>
    </xsl:variable>
    <xsl:result-document href="log/step2.log.xml">
      <xsl:sequence select="$step2"/>
    </xsl:result-document>
    <!-- finaly-->
    <xsl:sequence select="$step2"/>
  </xsl:template>

In another XSLT I need to add something within the body of the xhtml result of "convert2xhtml.xsl", so I load this result within a xsl:variable and then apply a new mode on it, something like :
<xsl:template match="/">
    <xsl:variable name="convert2xhtml" as="document-node()">
      <xsl:apply-templates select="." mode="convert2xhtml"/>
    </xsl:variable>
    <xsl:apply-templates select="$convert2xhtml" mode="addSomethingWithinBody"/>
</xsl:template>

While evaluating variable $convert2xhtml, some xsl:result-document will actually happen in convert2xhtml.xsl, which I find normal.
But it seems this is a conception problem ?

I could of course use some pipelining languages like xproc to do the stuff instead of those variable pipeline in XSLT, maybe we will do that later.
For the moment, I was just wondering about the reasons of this.
I add a debug parameter on convert2xhtml.xsl which I set to false when calling it from addSomethingToBody.xsl, it prevent the <xsl:result-document> to be executed and that "solve" the problem...

Any comments, suggestions ?
Should I send this post to the XSL-LIST or is it really tied to saxon behavior ?

Cheers

Matthieu Ricaud-Dussarget
Expert XML
SI EDITORIAL
[hidden email]
Tél : 01 40 92 21 98
80 Avenue de la Marne - 92120 Montrouge



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XTDE1480: Cannot execute xsl:result-document while evaluating variable

Martin Honnen-2
On 02.12.2016 16:57, Matthieu RICAUD-DUSSARGET wrote:

> We recently moved from saxon EE 9.5.1.5 to saxon EE 9.7.0.13 and we faced this problems
> "XTDE1480: Cannot execute xsl:result-document while evaluating variable"


> While evaluating variable $convert2xhtml, some xsl:result-document will actually happen in convert2xhtml.xsl, which I find normal.
> But it seems this is a conception problem ?
>
> I could of course use some pipelining languages like xproc to do the stuff instead of those variable pipeline in XSLT, maybe we will do that later.
> For the moment, I was just wondering about the reasons of this.
> I add a debug parameter on convert2xhtml.xsl which I set to false when calling it from addSomethingToBody.xsl, it prevent the <xsl:result-document> to be executed and that "solve" the problem...
>
> Any comments, suggestions ?
> Should I send this post to the XSL-LIST or is it really tied to saxon behavior ?

Well, that error code is defined in the XSLT 2.0 spec at
https://www.w3.org/TR/xslt20/#err-XTDE1480 and says

"It is a non-recoverable dynamic error to evaluate the
xsl:result-document instruction in temporary output state."

where the section
https://www.w3.org/TR/xslt20/#dt-temporary-output-state defines

"The second of the two output states is called temporary output state.
This state applies when instructions are writing to a temporary tree or
any other non-final destination."

so I think Saxon is right to raise the error when you have a sequence
constructor in an xsl:variable creating a temporary tree which also uses
xsl:result-document.




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XTDE1480: Cannot execute xsl:result-document while evaluating variable

Martin Honnen-2
On 02.12.2016 17:47, Martin Honnen wrote:

> On 02.12.2016 16:57, Matthieu RICAUD-DUSSARGET wrote:
>
>> We recently moved from saxon EE 9.5.1.5 to saxon EE 9.7.0.13 and we faced this problems
>> "XTDE1480: Cannot execute xsl:result-document while evaluating variable"
>
>
>> While evaluating variable $convert2xhtml, some xsl:result-document will actually happen in convert2xhtml.xsl, which I find normal.
>> But it seems this is a conception problem ?
>>
>> I could of course use some pipelining languages like xproc to do the stuff instead of those variable pipeline in XSLT, maybe we will do that later.
>> For the moment, I was just wondering about the reasons of this.
>> I add a debug parameter on convert2xhtml.xsl which I set to false when calling it from addSomethingToBody.xsl, it prevent the <xsl:result-document> to be executed and that "solve" the problem...
>>
>> Any comments, suggestions ?
>> Should I send this post to the XSL-LIST or is it really tied to saxon behavior ?
>
> Well, that error code is defined in the XSLT 2.0 spec at
> https://www.w3.org/TR/xslt20/#err-XTDE1480 and says
>
> "It is a non-recoverable dynamic error to evaluate the
> xsl:result-document instruction in temporary output state."
>
> where the section
> https://www.w3.org/TR/xslt20/#dt-temporary-output-state defines
>
> "The second of the two output states is called temporary output state.
> This state applies when instructions are writing to a temporary tree or
> any other non-final destination."
>
> so I think Saxon is right to raise the error when you have a sequence
> constructor in an xsl:variable creating a temporary tree which also uses
> xsl:result-document.

I have now tried a simple test case with XmlPrime, Exselt and Altova and
all three also raise the error XTDE1480.




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XTDE1480: Cannot execute xsl:result-document while evaluating variable

Michael Kay
In reply to this post by Matthieu RICAUD-DUSSARGET-2
The reason for the rule related to XTDE1480 is that evaluating a variable should not have side-effects; this is to ensure that optimizers have freedom to rewrite expressions for faster execution.

If 9.5 allows this construct then that's a bug. I suspect that we failed to check the condition in cases where the variable was inlined by the optimizer, and that our checking has now improved. This variable would be inlined because there is only one reference to it.

Michael Kay
Saxonica

> On 2 Dec 2016, at 15:57, Matthieu RICAUD-DUSSARGET <[hidden email]> wrote:
>
> Hi all,
>
> We recently moved from saxon EE 9.5.1.5 to saxon EE 9.7.0.13 and we faced this problems
> "XTDE1480: Cannot execute xsl:result-document while evaluating variable"
>
> This use to work fine with saxon 9.5, I was wondering if this is rather a saxon bogue or XSLT compliance of our code ?
>
> I could easily give the full example in a zip as private message, but it's giving a simple example is a bit time which I don't have unfortunately.
> Nevertheless I can explain what does the XSLT :
>
> There is an XSLT "convert2xhtml.xsl" which is multi-step using this kind of construct :
>
> <xsl:template match="/" mode="convert2xhtml">
>    <xsl:variable name="step1" as="document-node()">
>      <xsl:document>
>        <xsl:apply-templates select="." mode="step1"/>
>      </xsl:document>
>    </xsl:variable>
>    <xsl:result-document href="log/step1.log.xml">
>      <xsl:sequence select="$step1"/>
>    </xsl:result-document>
>    <xsl:variable name="step2" as="document-node()">
>      <xsl:document>
>        <xsl:apply-templates select="$step1" mode="step2"/>
>      </xsl:document>
>    </xsl:variable>
>    <xsl:result-document href="log/step2.log.xml">
>      <xsl:sequence select="$step2"/>
>    </xsl:result-document>
>    <!-- finaly-->
>    <xsl:sequence select="$step2"/>
>  </xsl:template>
>
> In another XSLT I need to add something within the body of the xhtml result of "convert2xhtml.xsl", so I load this result within a xsl:variable and then apply a new mode on it, something like :
> <xsl:template match="/">
>    <xsl:variable name="convert2xhtml" as="document-node()">
>      <xsl:apply-templates select="." mode="convert2xhtml"/>
>    </xsl:variable>
>    <xsl:apply-templates select="$convert2xhtml" mode="addSomethingWithinBody"/>
> </xsl:template>
>
> While evaluating variable $convert2xhtml, some xsl:result-document will actually happen in convert2xhtml.xsl, which I find normal.
> But it seems this is a conception problem ?
>
> I could of course use some pipelining languages like xproc to do the stuff instead of those variable pipeline in XSLT, maybe we will do that later.
> For the moment, I was just wondering about the reasons of this.
> I add a debug parameter on convert2xhtml.xsl which I set to false when calling it from addSomethingToBody.xsl, it prevent the <xsl:result-document> to be executed and that "solve" the problem...
>
> Any comments, suggestions ?
> Should I send this post to the XSL-LIST or is it really tied to saxon behavior ?
>
> Cheers
>
> Matthieu Ricaud-Dussarget
> Expert XML
> SI EDITORIAL
> [hidden email]
> Tél : 01 40 92 21 98
> 80 Avenue de la Marne - 92120 Montrouge
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XTDE1480: Cannot execute xsl:result-document while evaluating variable

Matthieu RICAUD-DUSSARGET-2
Hi Martin, Hi Michael,

Thanks Martin for the links to the spec and tests with other xslt processors.
Thanks Michael for the explanation with saxon 9.5.

I wasn't quite aware of "temporary output state" concept but I can fairly understand  that optimization issues are important while developing, especially in functional programing where preventing side-effects is the key !

We will probably have to change a few things in our design but on the other hand if this error lead us to optimize our XSLT, than it's a good thing it has been raised :)

Cheers and thanks again you both !

Matthieu






-----Message d'origine-----
De : Michael Kay [mailto:[hidden email]]
Envoyé : vendredi 2 décembre 2016 18:33
À : Mailing list for the SAXON XSLT and XQuery processor
Objet : Re: [saxon] XTDE1480: Cannot execute xsl:result-document while evaluating variable

The reason for the rule related to XTDE1480 is that evaluating a variable should not have side-effects; this is to ensure that optimizers have freedom to rewrite expressions for faster execution.

If 9.5 allows this construct then that's a bug. I suspect that we failed to check the condition in cases where the variable was inlined by the optimizer, and that our checking has now improved. This variable would be inlined because there is only one reference to it.

Michael Kay
Saxonica

> On 2 Dec 2016, at 15:57, Matthieu RICAUD-DUSSARGET <[hidden email]> wrote:
>
> Hi all,
>
> We recently moved from saxon EE 9.5.1.5 to saxon EE 9.7.0.13 and we
> faced this problems
> "XTDE1480: Cannot execute xsl:result-document while evaluating variable"
>
> This use to work fine with saxon 9.5, I was wondering if this is rather a saxon bogue or XSLT compliance of our code ?
>
> I could easily give the full example in a zip as private message, but it's giving a simple example is a bit time which I don't have unfortunately.
> Nevertheless I can explain what does the XSLT :
>
> There is an XSLT "convert2xhtml.xsl" which is multi-step using this kind of construct :
>
> <xsl:template match="/" mode="convert2xhtml">
>    <xsl:variable name="step1" as="document-node()">
>      <xsl:document>
>        <xsl:apply-templates select="." mode="step1"/>
>      </xsl:document>
>    </xsl:variable>
>    <xsl:result-document href="log/step1.log.xml">
>      <xsl:sequence select="$step1"/>
>    </xsl:result-document>
>    <xsl:variable name="step2" as="document-node()">
>      <xsl:document>
>        <xsl:apply-templates select="$step1" mode="step2"/>
>      </xsl:document>
>    </xsl:variable>
>    <xsl:result-document href="log/step2.log.xml">
>      <xsl:sequence select="$step2"/>
>    </xsl:result-document>
>    <!-- finaly-->
>    <xsl:sequence select="$step2"/>
>  </xsl:template>
>
> In another XSLT I need to add something within the body of the xhtml result of "convert2xhtml.xsl", so I load this result within a xsl:variable and then apply a new mode on it, something like :
> <xsl:template match="/">
>    <xsl:variable name="convert2xhtml" as="document-node()">
>      <xsl:apply-templates select="." mode="convert2xhtml"/>
>    </xsl:variable>
>    <xsl:apply-templates select="$convert2xhtml"
> mode="addSomethingWithinBody"/> </xsl:template>
>
> While evaluating variable $convert2xhtml, some xsl:result-document will actually happen in convert2xhtml.xsl, which I find normal.
> But it seems this is a conception problem ?
>
> I could of course use some pipelining languages like xproc to do the stuff instead of those variable pipeline in XSLT, maybe we will do that later.
> For the moment, I was just wondering about the reasons of this.
> I add a debug parameter on convert2xhtml.xsl which I set to false when calling it from addSomethingToBody.xsl, it prevent the <xsl:result-document> to be executed and that "solve" the problem...
>
> Any comments, suggestions ?
> Should I send this post to the XSL-LIST or is it really tied to saxon behavior ?
>
> Cheers
>
> Matthieu Ricaud-Dussarget
> Expert XML
> SI EDITORIAL
> [hidden email]
> Tél : 01 40 92 21 98
> 80 Avenue de la Marne - 92120 Montrouge
>
>
>
> ----------------------------------------------------------------------
> -------- Check out the vibrant tech community on one of the world's
> most engaging tech sites, SlashDot.org! http://sdm.link/slashdot 
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/ 
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...