This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Numbering elements by counting their representatives


Hi,

I'm processing a series of chapters as individual XML files.
Information about the logical integration of the chapters in the
complete document's hierarchy is kept in a DocBook "ToC" structure
held in a separate file, with the "tocentry" elements holding the file
names without ".xml" extension:

  <toc>
    <tocpart>
      <tocentry>Part_1</tocentry>
      <tocchap>
        <tocentry>First_Chapter</tocentry>
        <toclevel1>
          <tocentry>Section_ 1_1</tocentry>
        </toclevel1>
        <toclevel1>
          <tocentry>Section_1_2</tocentry>
        </toclevel1>
      </tocchap>
      <tocchap>
        <tocentry>Second_Chapter</tocentry>
        <toclevel1>
          <tocentry>Section_ 2_1</tocentry>
        </toclevel1>
      </tocchap>
    </tocpart>
  </toc>

Now, my question is: Which is the best (read: simplest or most
efficient) way to determine the current chapter's number when
processing its file? I tried to find the number of its corresponding
"tocchap" element by some ways using either count() or position().
Despite the examples given in Jeni's and Bob DuCharme's books and in
some FAQs, I couldn't come up with a solution.

I already dispose of some parameters or variables that probably should
be taken advantage of in this task:

<!-- global parameter holding name of structure description file
(abusing the DocBook "toc" structure to describe the whole
document's structure), passed via the command line -->
<xsl:param name="structure_description_filename"/>

<!-- global parameter holding name of current input file (without
".xml"), passed via the command line -->
<xsl:param name="current_filename"/>

<!-- description of the complete tree structure of all input files -->
<xsl:variable
  name="structure_description"
 
select="xalan:nodeset(document($structure_description_filename)/toc)"/>

<!-- XML node in the structure tree corresponding to the current input
file; locating it means finding a "tocentry" with a text child node
whose content is equal to the current file name -->
<xsl:param
  name="tocentry_for_current_file"
  select="$structure_description//tocentry[text() =
$current_filename]"/>

Any suggestions are greatly appreciated.

  Yves

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]