[xml] Changed XSLT processing?



I've just noticed that the xsltproc command line style sheet processor created by the libxslt-1.1.8 build generates a slightly different output from an xml file of mine than an earlier version.  I wonder if this was a deliberate design decision or an oversight.  To illustrate what I mean, here is a simplified version of the xml  file I am processing:
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DOCUMENT SYSTEM "http://myURI.dtd">
<DOCUMENT>
  <PRODUCT_NUMBER>P12345</PRODUCT_NUMBER>
  <TITLE ACRONYM="GSD">General Support Document</TITLE>
  <REVISION>
    <REV_LEVEL>01</REV_LEVEL>
    <REV_DATE>20030610</REV_DATE>
  </REVISION>
  <TOC>
    <CHAPTER NUMBER="FM" TITLE="DOC FRONT MATTER" FILE="fm.pdf" BYTES="10739909" />
    <CHAPTER NUMBER="11" TITLE="SOME CHAPTER TITLE">
      <SECTION NUMBER="FM" TITLE="Chapter Front Matter="11-fm.pdf" BYTES="85018" />
      <SECTION NUMBER="20" TITLE="Some Section Title" FILE="11-20.pdf" BYTES="2526128" />
      <SECTION NUMBER="21" TITLE="Ano ther Section Title" FILE="11-21.pdf" BYTES="1450631" />
      <SECTION NUMBER="30" TITLE="Third Section Title" FILE="11-30.pdf" BYTES="8972435" />
    </CHAPTER>   
    <CHAPTER NUMBER="80" TITLE="NEW CHAPTER TITLE">
      <SECTION NUMBER="FM" TITLE="Chapter Front Matter="80-fm.pdf" BYTES="85018" />
      <SECTION NUMBER="11" TITLE="Some Section Title" FILE="80-11.pdf" BYTES="2526128" />
      <SECTION NUMBER="99" TITLE="Another Section Title" FILE="80-99.pdf" BYTES="1450631" />
    </CHAPTER>
  </TOC>
</DOCUMENT>
 
The metadata is meant to contain the Table of Content (TOC) of a document where chapters may or may not have sections under them. The content of the chapters or sections is in pdf files.  My style sheet converts this metadata to a vertical bar (|) delimited flat file where the first column indicates the level of the TOC item (chapters are always level 1, sections are level 2), the 2nd column is the pdf file name if there is one, and the 3rd and last column is the chapter or section title.  Chapters having sections under them are not supposed to have their own pdf file, so their file column should be null; thus the two vertical bars should be next to each other. The prior version of xsltproc used to produce exactly that result with my style sheet, but the 1.1.8 release produces the following:
 
1|fm.pdf|FM DOC FRONT MATTER
1|NoFile|11 SOME CHAPTER TITLE
2|11-fm.pdf|11-FM, Chapter Front Matter
2|11-20.pdf|11-20, Some Section Title
2|11-21.pdf|11-21, Another Section Title
2|11-30.pdf|11-30, Third Section Title
1|NoFile|80  NEW CHAPTER TITLE
2|80-fm.pdf|80-FM, Chapter Front Matter
2|80-11.pdf|80-11, Some Section Title
2|80-99.pdf|80-99, Another Section Title
 
In other words it produces the "NoFile" string in the chapter rows where there is no file, instead of a null as it used to be before.   Here is my style sheet that produces the result:
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:apply-templates select="/DOCUMENT/TOC/CHAPTER"/>
</xsl:template>
<xsl:template match="CHAPTER">
<xsl:value-of select="count(../ancestor::*)"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@FILE"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@NUMBER"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@TITLE"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="SECTION"/>
</xsl:template>
<xsl:template match="SECTION">
<xsl:value-of select="count(../ancestor::*)"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@FILE"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="../@NUMBER"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="@NUMBER"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="@TITLE"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
 
Being fairly new to XSLT processing, I'm not sure how to modify my style sheet to produce the old results? Any hint would be greatly appreciated.
 
Thanks,
Rudy


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]