Re: FN-FORUM: replace string + xslt
date posted 31st July 2006 13:53
On Monday 31 July 2006 13:40, Rob Garbutt wrote:
>
> What's the best way (and easiest :-) to replace a string in xslt/xpath?
>
> I simply want to replace all instances of a string with another string. If
> any one can suggest, an example would be tops! :-)
>
It depends on the document context of the "strings" you're working with.
If its /just/ character data inside an XML document then the easiest thing to
do would be to use an ordinary text processing tool (text editor, sed, etc.).
If it has to be inside an XSLT transformation then you should take note of
XPath's string manipulation functions: contains(s1, s2), substring-before(s1,
s2), substring-after(s1, s2), substring(s1, start[, len]), concat(s, ...),
string-length(s), starts-with(s1, s2) and translate(s1, s2, s3) are the main
ones.
Also, XSLT2 includes a set of regular expression processing elements. Check
out the SAXON 8 processor: http://saxon.sf.net/
If you want to post your problem more specifially, then do and I'll have a
look.
Cheers,
Richard
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
Sonic Arts Research Archive
http://www.sara.uea.ac.uk/
JID: [EMAIL REMOVED]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-