Re: [xsl] given @id="1.2.3" .... -1 || +1 to the "3" in @id??

Subject: Re: [xsl] given @id="1.2.3" .... -1 || +1 to the "3" in @id??
From: "Anthony E." <apwebdesign@xxxxxxxxx>
Date: Mon, 2 Jul 2001 12:14:18 -0700 (PDT)
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.


--- 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 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: 

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

 XSL-List info and archive:

Current Thread