[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Problem with Output special char in HTML attribute
Subject: RE: [xsl] Problem with Output special char in HTML attribute From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 9 Dec 2004 11:38:00 -0000 |
> 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with Output speci, David Carlisle | Thread | Re: [xsl] Problem with Output speci, Fabio Cuomo |
RE: [xsl] recursive counter not inc, Michael Kay | Date | RE: [xsl] Problem applying XSL to X, Michael Kay |
Month |
Keywords