+1 to the "3" in @id

[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: given @id="1.2.3" .... -1 || +1 to the "3" in @id

Subject: RE: given @id="1.2.3" .... -1 || +1 to the "3" in @id??
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Mon, 2 Jul 2001 21:57:39 +0100
49 chris yahoo.com 2006
Anthony,
<xsl:value-of select="regExp:match(., '[0-9]+|\.', 'g')[5]" /> should do it.
Or
<xsl:value-of select="regExp:match(., '[0-9]+|\.',
'g')[count(regExp:match(., '[0-9]+|\.', 'g'))]" /> for any .00.00.00.00 Or
use tokenize
str:tokenize(., '.')

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Anthony E.
>Sent: 02 July 2001 20:14
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: Re:  given @id="1.2.3" .... -1 || +1 to the "3" in @id??
>
>
>following-sibling:: would work if the elements were
>all in the same file, but our application requires
>they be in separate xml files.
>
>i will have a "first" & "last" attribute in my element
>that contains the id of those elements, so i can
>compare with current id w/ 'first' or 'last' to see if
>there should be a prev or next link.
>
>My main concern here is the syntax of getting the
>substring after the last '.' in a string: ie - if
>id="1.22.33" or "1.2.3", how do specify the character
>position of the last '.', since it will not always be
>the 4th or 5th character in the string.
>
>--
>Anthony
>
>--- Trevor Nash <tcn@xxxxxxxxxxxxx> wrote:
>> 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 1.2.3.4 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
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail
>http://personal.mail.yahoo.com/
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.