xsl-list
[Top] [All Lists]

Re: Substring a Value

2004-08-09 08:05:11
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/



<Prev in Thread] Current Thread [Next in Thread>