[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problem with Output special char in HTML attribute
> The HTML output produced is: > > <html> > <body> > <p>text content</p><br/> > <a href="#" tabindex="1">link1</a> > <a href="#" tabindex="2">link2</a> > <a href="#" tabindex="3">link3</a> > <a href="#" tabindex="4">link4</a> > <a href="#" tabindex="5">link5</a> > </body> > </html> > > So, if i want to insert a new link, or change the position, or insert > new link between 2 links, i don't want to reorganize all tabindex of > the elements, but only insert tag and be able to generate correct > tabindex based on position. Then i need a mechanism that permits to > increment a variable to use as value of tabindex <a> attribute. All very clear until the last sentence, at which point you reveal that the only way you know how to solve this problem is the old procedural way. There are several mechanisms in XSLT for generating sequential numbers, and none of them involve incrementing counters. (a) xsl:number numbers nodes based on their position in the source tree. If all else fails, you can generate the output without numbers, and then add the numbers using xsl:number in a second pass (b) position() numbers nodes based on the order in which you process them (which is not necessarily related to their order in the source tree) (c) count(preceding-sibling::*) and similar constructs give you a lower-level equivalent to xsl:number. I'd need to see the complete structure of your transformation before advising which works best here, but the pipeline design, in which you do the transformation one step at a time, is always a good approach, and that would suggest constructing the tree first and then numbering it using xsl:number. Michael Kay http://www.saxonica.com/
|
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
|