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 56517 - Template priorities wrong for patterns with alternatives
Template priorities wrong for patterns with alternatives
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other other
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2001-06-22 01:36 UTC by stevecheng
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description stevecheng 2001-06-22 01:36:18 UTC
I think my stylesheets are giving your libxslt a good exercise :)

When a pattern has multiple subpatterns separated by '|',
only the first subpattern has the correct priority.

The following is a testcase:

The document
============

<?xml version='1.0'?>
<x>
</x>

The stylesheet
==============

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

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

<xsl:template match="x">
  <xsl:text>Matched x template</xsl:text>
  <xsl:apply-templates />
</xsl:template>

<!-- Case 1: y=0.0 /*=0.0, even though /* should be 0.5 -->
<!-- works if split up to: 
<xsl:template match="/*"> or of course you reverse the order
so the y pattern is screwed instead
-->
<xsl:template match="y|/*">
  <xsl:text>Matched /* or y template</xsl:text>
  <xsl:apply-templates />
</xsl:template>

<!--
Case 2: Here, both should have 5.0 priority but /* seems to have 0.0!
<xsl:template match="y|/*" priority="5.0">
  <xsl:text>Matched /* or y template</xsl:text>
  <xsl:apply-templates />
</xsl:template>
-->

</xsl:stylesheet>



Output
======
For both cases:

<?xml version="1.0"?>
<root>Matched x template
</root>

It should match the last template instead.  (Also see REC-XSLT, 5.5,
If the pattern contains alternatives, "it is treated equivalently to a
set of templates rules, one for each alternative.")

libxml, libxslt version: the ones from CVS.
Comment 1 Daniel Veillard 2001-06-23 12:38:13 UTC
Okay thanks a lot for the report and the tests. I took the
opportunity to clean this part a bit, fix 3 related bugs and
improve the debugging output. I think this is now fixed:

http://mail.gnome.org/archives/cvs-commits-list/2001-June/msg03754.html

orchis:~/XSLT/tests/general -> xsltproc -v bug-39-.xsl
../docs/bug-39-.xml
xsltParseStylesheetFile : parse bug-39-.xsl
Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform
xsltPrecomputeStylesheet: removing ignorable blank node
xsltParseStylesheetProcess : found stylesheet
xsltCompilePattern : parsing '/'
xsltCompilePattern : parsed /, default priority 0.500000
added pattern : '/' priority 0.500000
xsltCompilePattern : parsing 'x'
xsltCompilePattern : parsed x, default priority 0.000000
added pattern : 'x' priority 0.000000
xsltCompilePattern : parsing 'y'
xsltCompilePattern : parsed y, default priority 0.000000
xsltCompilePattern : parsing '/*'
xsltCompilePattern : parsed /*, default priority 0.500000
added pattern : 'y' priority 0.000000
added pattern : '/*' priority 0.500000
parsed 3 templates
Initializing keys on ../docs/bug-39-.xml
Registering global variables
Registering global variables from bug-39-.xsl
xsltProcessOneNode: applying template '/' for /
xsltApplyOneTemplate: copy node root
xsltApplyTemplates: list of 1 nodes
xsltProcessOneNode: applying template 'y|/*' for x
xsltApplyOneTemplate: copy text Matched /* or y template
xsltApplyTemplates: node: x
xsltApplyTemplates: list of 1 nodes
xsltProcessOneNode: no template found for text
xsltDefaultProcessOneNode: copy text 

<?xml version="1.0"?>
<root>Matched /* or y template
</root>
orchis:~/XSLT/tests/general -> 

  Oh, BTW use the -v flag to debug what's happening during a run.

  thanks again for the good bug report,

Daniel
Comment 2 Daniel Veillard 2001-06-27 06:31:07 UTC
should be closed in th 2.3.12 release,

thanks for the report !

Daniel