After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 351973 - default template application fails in context <xsl:copy>
default template application fails in context <xsl:copy>
Status: RESOLVED NOTABUG
Product: libxslt
Classification: Platform
Component: general
1.0.15
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-08-18 18:55 UTC by James Snavely
Modified: 2007-01-12 04:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description James Snavely 2006-08-18 18:55:53 UTC
Please describe the problem:
When applying the default template to a particular nodeset, no output is given for the command.

Steps to reproduce:
run the following XSL on the XML below it.
XSL:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    exclude-result-prefixes="exsl ">

<xsl:template mode="consolidate" match="@*|node()">
	<xsl:copy>
	<xsl:apply-templates mode="consolidate" select="@*|node()"/>
	</xsl:copy>
</xsl:template>

<xsl:template match="test">
	<xsl:copy>
	<xsl:apply-templates mode="consolidate"/>
	</xsl:copy>
</xsl:template>


<xsl:template mode="consolidate" match="fixme">

<xsl:variable name="all_nums">
<item><xsl:apply-templates select="one"/></item>
<item><xsl:apply-templates select="two"/></item>
<item><xsl:apply-templates select="three"/></item>
</xsl:variable>

	<move_numbers_here>
	<!--this fails -->
	<xsl:apply-templates select="exsl:node-set($all_nums)"/>

	<!--this works
	<xsl:copy-of select="exsl:node-set($all_nums)"/>
-->
	</move_numbers_here>
</xsl:template>

<xsl:template match="/">
<xsl:apply-templates select="test"/>
</xsl:template>

</xsl:stylesheet>

XML input file:
<test>
<fixme>
<one>1</one>
<two>2</two>
<three>3</three>
<move_numbers_here/>
</fixme>
</test

Actual results:
The node "move_numbers_here" has no content.
xsltproc test.xsl test.xml
<?xml version="1.0"?>
<test>
<move_numbers_here/>
</test>


Expected results:
I would expect the output to look like this:
<?xml version="1.0"?>
<test>
<move_numbers_here><item>1</item><item>2</item><item>3</item></move_numbers_here>
</test>


Does this happen every time?
Yes. But previous versions of LibXSLT gave the expected output, rather then the empty node we see now.

Other information:
Using <xsl:copy-of> gives the output I expected from <xsl:apply-templates> 
Please see example code.
Comment 1 William M. Brack 2007-01-12 04:04:56 UTC
I believe this is a result of the recent enhancements to libxslt, and that the current behaviour is correct.  At the time you create your variable "all_nums", an RVT
     <item>1</item><item>2</item><item>3</item>
is produced.  When you then
     <xsl:apply-templates select="exsl:node-set($all_nums)"/>
there are no templates (or, more precisely, none with an absent "mode") which match these nodes, so no output is produced.  If, for example, you change this to:
     <xsl:apply-templates select="exsl:node-set($all_nums)" mode="consolidate"/>
you will get the output you expect.