[XML-SIG] [ pyxml-Bugs-418808 ] [4XSLT] Bug in precise/general match

noreply@sourceforge.net noreply@sourceforge.net
Wed, 25 Apr 2001 05:26:27 -0700


Bugs item #418808, was updated on 2001-04-25 05:26
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=106473&aid=418808&group_id=6473

Category: 4Suite
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Logilab (ornicar)
Assigned to: Nobody/Anonymous (nobody)
Summary: [4XSLT] Bug in precise/general match

Initial Comment:
Hello,

I was writing an XSL stylesheet for processing docbook
XML files when I discovered a very strange behaviour of
4XSLT that looks like a bug.

Consider the following XML file (testbug.xml):
  <?xml version="1.0" encoding="ISO-8859-1"?>

  <section>
   <para>This is a paragraph.</para>
   <formalpara>
    <title>Title</title>
    <para>This is a formal paragraph.</para>
   </formalpara>
  </section>

And the following XSLT file (testbug1.xslt):
  <?xml version="1.0" encoding="ISO-8859-1"?>

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

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

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

   <xsl:template match="formalpara">
    <p>
     <xsl:apply-templates select="title"/>
     <xsl:apply-templates select="para"/>
    </p>
   </xsl:template>

   <xsl:template match="formalpara/title">
    <b><xsl:apply-templates/>: </b>
   </xsl:template>

  </xsl:stylesheet>

  Processing the XML file with the XSLT file gives the
following result:
  <p>This is a paragraph.</p>
  <p><b>Title: </b>This is a formal paragraph</p>

You have noticed that the template for processing a
<para> node is different if the <para> node is child of
<formalpara> node or not. 4XSLT chooses the template
with the most precise matching condition that matches
the current node (and this is what is written in the
XSLT norm).

  Now, consider the following XSLT file
(testbug2.xslt):
  <?xml version="1.0" encoding="ISO-8859-1"?>

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

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

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

   <xsl:template match="formalpara">
    <p>
     <xsl:apply-templates select="title"/>
     <xsl:apply-templates select="para"/>
    </p>
   </xsl:template>

   <xsl:template match="formalpara/title">
    <b><xsl:apply-templates/>: </b>
   </xsl:template>

  </xsl:stylesheet>

You have noticed that the only modification I did was
to permute the "para" template and the
"formalpara/para" template.

  Processing the same XML file with this new XSLT file
outputs the following result:
  <p>This is a paragraph.</p>
  <p><b>Title: </b><p>This is a formal
paragraph.</p></p>

Now, 4XSLT doesn't use the "formalpara" template for
the <para> node child of <formalpara> but the "para"
template (thus we have nested <p> nodes in the output). 

  I feel that instead of choosing the template with the
most precise matching condition that matches the
current node, 4XSLT chooses the first one. Therefore,
my two XSLT that should have the same behaviour, output
two different results.

  Regards,

    O. CAYROL.

PS: I tried xalan on these examples and I got the same
result for each XSLT (just as I expected).


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=106473&aid=418808&group_id=6473