I want to find the position() of an element in an xml file
among its type. for example <book> <title>Introduction to
Algorithms</title> <author>Cormen</author>
<author>Leiserson</author> ... <author>Rivest</author> </book>
I want to get (1) for Cormen, (2) for Leiserson and (3) for
Rivest. using the normal position() function will return 2,3
and 5 resepctively.
The position() function returns the index of the element within the
current element list. Between each <author> element you have a
whitespace text node, which is being included in the current element
list giving you the results you're seeing.
There are many ways to solve this, but without seeing your stylesheets
I'll just have to list a few:
- Use count(preceding-sibling::author) instead of position()
- Be more specific when selecting processing the <author> elements
- If you are using node(), use * instead as this only selects element
nodes
- Use xsl:strip-space to remove unwanted presentational whitespace
If you post the template it would be easier to suggest a fix...
cheers
andrew
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--