|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: index of an element among its type
> 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
|
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








