[XML-SIG] [Bug #125186] xsl:number fails for two-level numbering

noreply@sourceforge.net noreply@sourceforge.net
Sat, 9 Dec 2000 14:14:26 -0800


Bug #125186, was updated on 2000-Dec-09 14:14
Here is a current snapshot of the bug.

Project: Python/XML
Category: 4Suite
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: nobody
Assigned to : nobody
Summary: xsl:number fails for two-level numbering

Details: Consider the following stylesheet.

<?xml version="1.0"?>

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

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

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

  <xsl:template match="div1/head">
    <h2>
      <xsl:apply-templates select=".." mode="divnum"/>
      <xsl:apply-templates/>
    </h2>
  </xsl:template>

  <xsl:template match="div2/head">
    <h3>
      <xsl:apply-templates select=".." mode="divnum"/>
      <xsl:apply-templates/>
    </h3>
  </xsl:template>

  <xsl:template mode="divnum" match="div1">
    <xsl:number format="1 "/>
  </xsl:template>

  <xsl:template mode="divnum" match="div2">
    <xsl:number level="multiple" count="div1 | div2" format="1.1 "/>
  </xsl:template>

</xsl:transform>

Apply this to the following XML:

<?xml version="1.0"?>
<book>
<div1>
  <head>Chapter 1</head>
  Chapter 1 content.
  <div2>
    <head> Section 1.1</head>
    Section 1.1 content.
  </div2>
  <div2>
    <head> Section 1.2</head>
    Section 1.2 content.
  </div2>
</div1>
<div1>
  <head>Chapter 2</head>
  Chapter 2 content.
  <div2>
    <head> Section 2.1</head>
    Section 2.1 content.
  </div2>
  <div2>
    <head> Section 2.2</head>
    Section 2.2 content.
  </div2>
</div1>
</book>

The result is:

<?xml version='1.0' encoding='UTF-8'?>



  
<h2>1 Chapter 1</h2>
  Chapter 1 content.
  
    <h3>3  Section 1.1</h3>
    Section 1.1 content.
  
  
    <h3>3  Section 1.2</h3>
    Section 1.2 content.
  


  <h2>2 Chapter 2</h2>
  Chapter 2 content.
  
    <h3>4  Section 2.1</h3>
    Section 2.1 content.
  
  
    <h3>4  Section 2.2</h3>
    Section 2.2 content.

As you can see, the level two numbers are wrong.  Instead of e.g. "2.2", it gives a single number, which appears to the be total of all div1 through the current one, plus div2 elements through the current entire div1 section.  In other words, Section 2.1 is numbered as "4" since there are two div1 sections up through 2.2, and two div2 sections in the second div1 section.  

This is a subset of the "xmlspec.xsl" file, used to transform W3C specifications.

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