Preceding axe
Added by Anonymous about 16 years ago
Legacy ID: #5222524 Legacy Poster: Willem van Heerde (wheerde)
Hello Michael Kay, I have a problem with the preceding axe. I have the following test xml: <aa> <nn/> <cc> <pp/> <ee> <dd/> </ee> </cc> </aa> and the stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template name="sheet" match="/"> <pre><xsl:copy-of select="//ee/preceding::"/></pre> <sib><xsl:copy-of select="//ee/preceding-sibling::"/></sib> </xsl:template> </xsl:stylesheet> The preceding-sibling axe gives the result I expected; namely only element <pp>. The preceding axe however also results element <nn> ??? I would suspect the same result; namely element <pp>. Is this a bug? Thanx, Willem. I have tested it with saxon 9.1.0.2j.
Replies (2)
RE: Preceding axe - Added by Anonymous about 16 years ago
Legacy ID: #5222551 Legacy Poster: Michael Kay (mhkay)
No, it's not a bug. Please read the specification again. "the preceding axis contains all nodes that are descendants of the root of the tree in which the context node is found, are not ancestors of the context node, and occur before the context node in document order" You might find the diagram on page 612 of my book (XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th ed) helpful.
RE: Preceding axe - Added by Anonymous about 16 years ago
Legacy ID: #5222988 Legacy Poster: Willem van Heerde (wheerde)
I think I got it, preceding also means the preding elements (and their childs) of the ancestors?
Please register to reply