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

Re: Substring a Value

Subject: Re: Substring a Value
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 9 Aug 2004 16:05:11 +0100
xsl substring indexof
Hi Trevor,

> where, <xsl:value-of select="@from"/> (the value returned) needs to be
> substringed(2, len(@from)-1).

The example you gave was "ID(0DP_12345)" from which you wanted
"ODP_12345". In XPath syntax, you need:

  substring(@from, 4, string-length(@from) - 4)

The first argument is the string you want to substring. The second is
the index of the first character in the substring that you want (XPath
counts from 1 rather than 0). The third argument is the *length* of
the substring that you want.

Alternatively, you could use:

  substring-before(substring-after(@from, 'ID('), ')')

which is easier if you can't count so well!

> I have tried several JavaScripts, but I can't seem to get anything
> to work.

You're using XSLT, not Javascript. Take a look at the XPath quick
reference from: http://www.mulberrytech.com/quickref/index.html

> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

Oh, I take it back, you're not using XSLT at all, but WD-xsl, the
defunct dialect once used in IE. Take a look at the MSXML FAQ at:

  http://www.netcrucible.com/xslt/msxml-faq.htm

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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.