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

Re: string replacement for HTML tags

Subject: Re: string replacement for HTML tags
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 25 Apr 2002 17:28:41 -0400
sed recursive replacement
Daniel:

I agree with Joerg, with the following caveats:

* Keep in mind, as always, that relying on disable-output-escaping ties your process both to an XSLT engine that implements d-o-e, and to a particular processing model (the result tree must be serialized to a character stream for the transform to be complete). If you can live with that, cool.

* You're going to have to watch out for "real" bracket characters in your data ... they too will be converted to < and >. Short of fancy and error-prone heuristics, there is no way around this, since your problem itself violates the first principle of the markup paradigm on which XSLT is based, which might be phrased (with apologies to Kipling fans -- oops, I forget, there are no Kipling fans any more): "Data is data and markup is markup, and never the twain shall meet". (This would be true even if you did it the recursive way.)

* For the same reason, there's no way of assuring that the output you get will be well-formed XML until you already have it and are able to test it.

The same transform could be done as easily, or more so, with Perl or sed. (Indeed, better, since their support of regular expressions gives you at least some hope of working around any real brackets that might turn up.)

Cheers,
Wendell

At 04:34 PM 4/25/2002, Joerg wrote:
Hello Daniel,

I think this is a legitimate use case for disable-output-escaping.

<xsl:template match="data">
  <xsl:value-of disable-output-escaping="yes"
      select="translate(., '[]', '&lt;&gt;')"/>
</xsl:template>

So with translate() you don't need a recursive approach.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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-2011 All Rights Reserved.