[XML-SIG] [Bug #128172] [4XSLT] strange behaviour of xsl:import

nobody nobody@sourceforge.net
Tue, 09 Jan 2001 07:38:50 -0800


From: noreply@sourceforge.net

Bug #128172, was updated on 2001-Jan-09 07:38
Here is a current snapshot of the bug.

Project: Python/XML
Category: 4Suite
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: ornicar
Assigned to : nobody
Summary: [4XSLT] strange behaviour of xsl:import


Details:  Hello,

  I'm using XSL Transformation to turn xml trees in viewable html
documents (again!) and I've just found something looking like a bug in
4xslt engine.

  The attached xml file (carpool.xml) contains data on a pool of cars.
Each <car> node has a 'state' attribute used to know if the car is free or
used or in the garage for maintenance. The 'state' value is a number.

    <car state="1">
      <brand> ... </brand>
      ...
    </car>

  In order to display valuable information on a web page, I use the
attached xslt stylesheet (pool2html.xsl) and I transform the 'state'
numeric value to an understandable string. As this number-to-string
transformation should be used in various stylesheets, I put it in a
named-template stored in a common XSLT stylesheet (pool-comm.xsl). This
common stylesheet is imported at the beginning of pool2html.xsl
stylesheet.

    <xsl:stylesheet ...>
      <xsl:import href="pool-comm.xsl"/>
      ...
      <xsl:template match="car">
        ...
        <xsl:call-template name="state-value"/>
        ...
      </xsl:template>
    </xsl:stylesheet>

  What I expected to get is the attached html document called
expected-pool.html . Nevertheless, I got the attached html document called
pool.html ! 4xslt wasn't able to call the template named 'state-value'
whereas this template is defined in the imported stylesheet
(pool-comm.xsl). Another XSLT engine (e.g. xalan) is able to call the
template and outputs the expected html.

  A stranger behaviour : when I replace the 'xsl:import' with an
'xsl:include', 4xslt can call the named-template and outputs the expected
html.
  I read very carefully the XSLT spec and I didn't find any possible
explanation to this strange behaviour ... could you let me know if this is
a bug or if there is something I didn't get in stylesheets combination
philosophy.

  Best regards, 

    O. CAYROL.

-------------------------------------------------------
carpool.xml
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>

<!DOCTYPE pool>

<pool>
  <car state="1">
    <brand>Ferrari</brand>
    <type>F40</type>
    <number>459 CBO 75</number>
  </car>
  <car state="2">
    <brand>Porsche</brand>
    <type>911</type>
    <number>347 CQQ 75</number>
  </car>
</pool>
-----------------------------------------------------
pool2html.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>

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

  <xsl:import href="pool-comm.xsl"/>

  <xsl:output method="html" 
              version="4.0" 
              encoding="ISO-8859-1" 
              indent="yes" 
              doctype-public="-//W3C//DTD HTML 4.0//EN"/>

  <xsl:template match="/">
<html>
 <head>
  <title>Cars Pool Management</title>
  <meta http-equiv="content-type" content="text/html"/>
 </head>

 <body bgcolor="#FFFFFF">
  <h1>Cars Pool Management</h1>
  <table border="1" cellpadding="3">
   <tr>
    <td>State</td>
    <td>Brand</td>
    <td>Type</td>
    <td>Registration Number</td>
   </tr>

    <xsl:apply-templates select="pool/car"/>

  </table>
 </body>
</html>
  </xsl:template>

  <xsl:template match="car">
<tr>
 <td>
    <xsl:call-template name="state-value"/>
 </td>
 <td>
    <xsl:value-of select="brand"/>
 </td>
 <td>
    <xsl:value-of select="type"/>
 </td>
 <td>
    <xsl:value-of select="number"/>
 </td>
</tr>
  </xsl:template>

</xsl:stylesheet>
 -------------------------------------------------------
pool-comm.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>

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

  <xsl:template name="state-value">
    <xsl:choose>
      <xsl:when test="@state=1">
        <b>Free</b>
      </xsl:when>
      <xsl:when test="@state=2">
        Used
      </xsl:when>
      <xsl:when test="@state=3">
        <i>Getting repaired</i>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
---------------------------------------------------
pool.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
  <head>
    <META HTTP-EQUIV='Content-Type' CONTENT='text/html;
charset=ISO-8859-1'>
    <title>Cars Pool Management</title>
    <meta content='text/html' http-equiv='content-type'>
  </head>
  <body bgcolor='#FFFFFF'>
    <h1>Cars Pool Management</h1>
    <table cellpadding='3' border='1'>
      <tr>
        <td>State</td>
        <td>Brand</td>
        <td>Type</td>
        <td>Registration Number</td>
      </tr>
      <tr>
        <td></td>
        <td>Ferrari</td>
        <td>F40</td>
        <td>459 CBO 75</td>
      </tr>
      <tr>
        <td></td>
        <td>Porsche</td>
        <td>911</td>
        <td>347 CQQ 75</td>
      </tr>
    </table>
  </body>
</html>
----------------------------------------------------
expected-pool.html 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
    <head>
        <title>Cars Pool Management</title>
        <meta http-equiv="content-type" content="text/html">
    </head>
    <body bgcolor="#FFFFFF">
        <h1>Cars Pool Management</h1>
        <table border="1" cellpadding="3">
            <tr>
                <td>State</td><td>Brand</td><td>Type</td><td>Registration
Number
</td>
            </tr>
            <tr>
                <td><b>Free</b></td><td>Ferrari</td><td>F40</td><td>459 CBO
75</
td>
            </tr>
            <tr>
                <td>
        Used
      </td><td>Porsche</td><td>911</td><td>347 CQQ 75</td>
            </tr>
        </table>
    </body>
</html>





For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=128172&group_id=6473