Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to get last value in delimited string?

Reply
Thread Tools

How to get last value in delimited string?

 
 
bearclaws
Guest
Posts: n/a
 
      01-28-2005
I'm new to XML/XSL and need to get the last value from a string that
looks like this (where the colon is the delimiter)...

Computersrives:Firewire:Hard Drive

I have an XSL file that gets this whole string passed to it as a
variable, but I just want to write "Hard Drive" to the screen.
Any suggestions?

Thanks,
BC

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      01-28-2005
Tempore 19:00:10, die Friday 28 January 2005 AD, hinc in foro {comp.text.xml} scripsit bearclaws <(E-Mail Removed)>:

> Computersrives:Firewire:Hard Drive
>
> I have an XSL file that gets this whole string passed to it as a
> variable, but I just want to write "Hard Drive" to the screen.
> Any suggestions?

Hi,

this is an XSLT1.0 solution:

<xsl:template name="tail">
<xslaram name="string" select="."/>
<xsl:choose>
<xsl:when test="substring-after($string,':')">
<xsl:call-template name="tail">
<xsl:with-param name="string" select="substring-after($string,':')"/>
</xsl:call-template>
</xsl:when>
<xsltherwise>
<xsl:value-of select="$string"/>
</xsltherwise>
</xsl:choose>
</xsl:template>call the template with e.g.:

<xsl:call-template name="tail">
<xsl:with-param name="string" select="$variable"/>
</xsl:call-template>

(by default, it will select the string value of the context node)

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Deserta faciunt et innovationem appelant
 
Reply With Quote
 
 
 
 
bearclaws
Guest
Posts: n/a
 
      01-28-2005
This worked perfectly

Can you recommend any sites or books that will help me learn more about
XSLT (i.e. with examples like the one you provided)?
Many thanks!

>>BC


 
Reply With Quote
 
Joris Gillis
Guest
Posts: n/a
 
      01-29-2005
Tempore 21:28:34, die Friday 28 January 2005 AD, hinc in foro {comp.text.xml} scripsit bearclaws <(E-Mail Removed)>:

> Can you recommend any sites or books that will help me learn more about
> XSLT (i.e. with examples like the one you provided)?


This is a good site:
http://www.jenitennison.com/xslt/

I myself learned XSLT with experimenting and reading this newsgroup.
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert non-delimited to delimited RyanL Python 6 08-28-2007 12:06 AM
How to replace the last (and only last) character in a string? Johny Python 8 05-03-2007 09:24 PM
how to delete last node of a Linked list if you only know the address of last node. sangram C Programming 16 12-01-2006 08:57 PM
Help ASP; get last inserted value from one table, insert multiple rows in another table. PT ASP General 1 10-07-2004 07:27 AM
Get tab delimited results Niraj Khandwala ASP General 5 08-02-2004 01:12 PM



Advertisments