GNOME Bugzilla – Bug 53923
select in apply-templates ?
Last modified: 2009-08-15 18:40:50 UTC
The select in apply-template element does not seem to find the last element. (test files taken from www.zvon.org) [rchaillat@pc-1229]$ cat apply-select.xsl <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output method = "text" /> <xsl:template match = "/" > <xsl:apply-templates select = "//BBB" /> </xsl:template> <xsl:template match = "BBB" > <xsl:text> BBB[</xsl:text> <xsl:value-of select = "position()" /> <xsl:text >]: </xsl:text> <xsl:value-of select = "." /> </xsl:template> </xsl:stylesheet> [rchaillat@pc-1229]$ cat apply-select.xml <AAA> <BBB>10 </BBB> <BBB>5 </BBB> <BBB>7 </BBB> </AAA> [rchaillat@pc-1229 .gnobog]$ xsltproc apply-select.xsl apply-select.xml BBB[1]: 10 BBB[2]: 5 * Expected output : BBB[1]: 10 BBB[2]: 5 BBB[3]: 7 Happy debugging ;-) Renaud
Check taht your shell output didn't covered the last line of the XSLT output :-) orchis:~/XSLT/tests/general -> xsltproc bug-20-.xsl ../docs/bug-20-.xml BBB[1]: 10 BBB[2]: 5 BBB[3]: 7 orchis:~/XSLT/tests/general -> The best way to check if and where something went wrong is to give the -v flag to xsltproc: orchis:~/XSLT/tests/general -> xsltproc -v bug-20-.xsl ../docs/bug-20-.xml xsltParseStylesheetFile : parse bug-20-.xsl Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform xsltPrecomputeStylesheet: removing ignorable blank node xsltParseStylesheetProcess : found stylesheet xsltCompilePattern : parsing '/' added pattern : '/' priority 0.000000 xsltCompilePattern : parsing 'BBB' added pattern : 'BBB' priority 0.000000 parsed 2 templates Initializing keys on ../docs/bug-20-.xml Evaluating global variables xsltProcessOneNode: applying template for / xsltApplyTemplates: node: (null) xsltApplyTemplates: select //BBB xsltApplyTemplates: list of 3 nodes xsltProcessOneNode: applying template for BBB [etc...] Daniel