[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

Subject: RE: Problem with Output special char in HTML attribute
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 9 Dec 2004 11:38:00 -0000
special char
> 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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.