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

Placing mark-up in between strings

Subject: Placing mark-up in between strings
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Thu, 23 Nov 2006 11:46:08 +0800
 Placing mark-up in between strings
Hi,

I have this function (thanks to sir M. Kay) that search and replaces all occurrences of a sequence of search string with its corresponding replacement string.

<xsl:function name="ati:replace-all">
<xsl:param name="input" as="xs:string"/>
<xsl:param name="words-to-replace" as="xs:string*"/>
<xsl:param name="replacement" as="xs:string*"/>
<xsl:sequence select="if (exists($words-to-replace)) then ati:replace-all(replace($input, $words-to-replace[1], $replacement[1]),remove($words-to-replace,1),remove($replacement,1)) else $input"/>
</xsl:function>


Can this be modified so that I can place the search string inside an element and the replacement string inside an attribute?

I have this as a sample:

<p>This is supposed to be my input string with search1, search2, and search3.</p>

I want this to be:

<p>This is supposed to be my input string with <replacement value="replacement1">search1</replacement>, <replacement value="replacement2">search2</replacement>, and <replacement value="replacement3">search3</replacement>.</p>

Thanks,
Jeff

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.