xsl-list
[Top] [All Lists]

Re: [xsl] Using XSLT to do a search & replace

2011-04-21 16:41:57
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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