Re: given @id="1.2.3" .... -1 || +1 to the "3" in @id
There are two answers to this (at least ;-) >given @id="1.2.3", how do I add or subtract 1 from the >'.3' in the string "1.2.3" in a stylesheet? > >I need to create "prev | next" links generated from >the current @id number for a file. ie - 'prev' link >would be equal to '1.2.2', and 'next' link would be >equal to '1.2.4' > The first is to point you at the substring() and concat() functions (in XPath rather than XSLT, if you are working from the specs) which you can use to rip the string apart, do the required arithmetic, and glue it all back together again. Conversion between numbers and strings is usually implicit, though you can use string() and number() if you need to or prefer to be explicit. Yes, you can write Basic programs in XSLT ;-)) Assuming you need to deal with id's of different lengths such as 23.4.874 or 18.104.22.168 you may need to look up recursive templates to help you do the ripping apart. The second answer is that you probably do not want to do it like this at all. How do you know that the next link for 1.2.3 is 1.2.4 and not 1.3 or 1.3.1 or even nothing at all? It is much more likley that you should be navigating to the next node within your XML document perhaps using following:: or following-sibling:: then simply copying the @id you find there. This has the added benefit that it would still work if your identifiers were like 1.2.a. Without seeing your XML and knowing whether you can change its design it is hard to advise further. Regards, Trevor Nash XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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