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

Re: Using XSLT to do a search & replace

Subject: Re: Using XSLT to do a search & replace
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 21 Apr 2011 22:41:44 +0100
Re:  Using XSLT to do a search & replace
On 21/04/2011 19:09, Bubba O'Reily wrote:



Hi,


I have a XML file that I want to transform. I want to be able to do a
search&  replace on elements in the XML and replace them. For example:

Replace<para>  with [ParaStyle:para]
Replace<text>  with [ParaStyle:text]

etc...


Just turn each of these rules into an XSLT template rule:


<xsl:template match="para">
[ParaStyle:para]<xsl:apply-templates/>[/ParaStyle:para]
</xsl:template>

<xsl:template match="text">
[ParaStyle:text]<xsl:apply-templates/>[/ParaStyle:text]
</xsl:template>

I've had to make guesses there about what the true requirement is, including whitespace handling.

Michael Kay
Saxonica

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.