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

Re: Multiple replace() in XSLT 2

Subject: Re: Multiple replace() in XSLT 2
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 May 2019 19:34:56 -0000
Re:  Multiple replace() in XSLT 2
I think recursion is the easiest solution in XSLT 2.0.

In 3.0 you can use xsl:iterate, or a fold() operation:

fold-left($input, $lookup/*/findChange, function($a, $c) { replace($a,
$c/@find, $c/@change, 'q' })

Michael Kay

> On 16 May 2019, at 19:59, Rick Quatro rick@xxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
> I have a look up file of find/change pairs that I have to apply to a text
node in my XML document. I am using XSLT 2. Here is an example of the lookup
> <?xml version="1.0" encoding="UTF-8"?>
> <findchange_lookup>
>     <findchange find="Eicas" change="EICAS"/>
>     <findchange find="Ulb" change="ULB"/>
> </findchange_lookup>
> I am reading this in as a global variable, but I am not sure the best
approach for doing multiple replacements on the node. I can use recursion like
in XSLT 1, but I can't think of how to do this in XSLT 2. There could be any
number of <findchange> elements in my lookup file. Any pointers would be
appreciated. Thank you very much.
> Rick
> Rick Quatro
> Carmen Publishing Inc.
> rick@xxxxxxxxxxxxxxx <mailto:rick@xxxxxxxxxxxxxxx>
> 585-729-6746
> www.frameexpert.com/store/ <http://www.frameexpert.com/store/>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

Current Thread


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.
First Name
Last Name
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.