|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Different parsers, different behaviour!
Thanks very much for the links to command line XML (etc.) utilities. I've installed and played with the XMLStarlet one (mainly because its not Java!) However, something a bit weird is going on: I have an XML document with the following structure: <index> <item> <title>...</title> <author>...</author> <pages>nn</pages> </item> <item> <title>...</title> <author>...</author> <pages>nn</pages> </item> .... </index> Its just an index of a bunch of pieces of sheet music in PDF format. The 'pages' element stores the number of pages each piece is presented on. What I wanted to do was make a 'Contents' page for presenting the pieces in a booklet format. It just lists the pieces in alphbetical order and calculates and displays which page they should start on. I used two stylesheets; one just sorts the source document and passes its result to the second, which makes the contents page, and looks like this: <xsl:stylesheet version="1.0" xmlns:xsl="..."> <xsl:output method="html" /> <xsl:template match="/"> <html> <body> <h3>Collection</h3> <hr /> <table border="0" cellspacing="3" width="100%"> <xsl:apply-templates select="//item" /> </table> <hr /> </body> </html> </xsl:template> <xsl:template match="item"> <tr> <td><xsl:value-of select="position()" /></td> <xsl:apply-templates /> </tr> </xsl:template> <xsl:template match="title"> <td><xsl:apply-templates /></td> </xsl:template> <xsl:template match="author"> <td><xsl:apply-templates /></td> </xsl:template> <xsl:template match="pages"> <td align="right"><xsl:value-of select="sum(preceding::pages) + 1" /></td> </xsl:template> </xsl:stylesheet> Does this look like it should work? (particularly the match="pages" template) It didn't work with the parser I normally use (Sablatron 1.0); it seems that 'sum(preceding::pages)' was always 1 less that it should be. But when I tried the stylesheet (unaltered) using XMLStarlet it produced exactly the correct output! Whats going on?! Cheers, Richard 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
|

Cart








