[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|