dayvonjersen / ajaxslt

Automatically exported from code.google.com/p/ajaxslt
Other
0 stars 0 forks source link

xsl:variable issue #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run this code:
<xsl:stylesheet>
  <xsl:template match="/">
    <xsl:variable name="header">
      <tr>
        <th>Element</th>
        <th>Description</th>
      </tr>
    </xsl:variable>

    <xsl:apply-templates select="page/message"/>
  </xsl:template>

  <xsl:template match="page/message">
    <div>
      <xsl:value-of select="."/>
    </div>
  </xsl:template>
</xsl:stylesheet>

using this XML:
<page>
<message>
Hello World.
</message>
</page>

What is the expected output? What do you see instead?
I expect that a local variable will be created in the root template. That
can be used later. The final output should be:
<div>
Hello World.
</div>

What I actually get is an error that crashes the javascript. When I view
the javascript console in FireFox this is what the error comes up as:
Error: input.node.ownerDocument has no properties
Source File: xslt.js
Line: 356

What version of the product are you using? On what operating system?
I am using version 0.5 on a PC.

Original issue reported on code.google.com by lea...@gmail.com on 8 Dec 2006 at 7:49

GoogleCodeExporter commented 8 years ago
Will be fixed soon. Btw. if you want the variable to be global, you should 
define
them at the top level (i.e. below xsl:stylesheet), and not below the 
xsl:template
that matches the root node.

Original comment by steffen....@gmail.com on 16 Dec 2006 at 1:32

GoogleCodeExporter commented 8 years ago
Here's a patch (against svn revision 7) that AFAICS solves the issue. I've 
tested
some of the different xsl:variable usage possibilities, and they all seem to 
work.

Original comment by bjpbak...@gmail.com on 18 Dec 2006 at 4:47

Attachments:

GoogleCodeExporter commented 8 years ago
That's an appropriate fix.

It turned out that the nodes in the nodeset value of the variable could be 
created
from any of the three DOMs of input, template, and output, and it seems that my
choice to use the input document is conceptually the least appropriate, although
practically I can't think of any difference it would make.

In my upcoming fix I chose to create the nodes in the variable value from the
template document instead, and the template node at this poitn is guranteed to 
be an
element (the xsl:variable element in fact) and hence have an ownerDocument.

Either way is fine, as far as I can see.

Original comment by steffen....@gmail.com on 18 Dec 2006 at 6:49

GoogleCodeExporter commented 8 years ago
Fixed in release-0-7.

Original comment by steffen....@gmail.com on 29 Dec 2006 at 2:20