Re: [xsl] XSL transform escape question

Subject: Re: [xsl] XSL transform escape question
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 9 Sep 2002 12:10:32 -0600 (MDT)
Holmberg Rick-ra0119 wrote:
> I am processing an xml file with html tags in it.

Sorry to be unsympathetic, but there's your problem.
This is a FAQ.

> When I do the transform (using the transform method with
> the SAX parser)

XML parsers generally don't transforms, except identity transforms.
You mean an XSLT processor.

> it is translating the < to &lt and > to &gt.

...as it is required to do (at least with "<"), when those start-of-markup
characters appear in a portion of the XML that is clearly intended to be
character data, not markup. XSLT does not provide for the possibility of
interpreting character data as markup; that's the job of an XML parser.

> I just want the < to remain as a < and not have the conversion
> take place.

disable-output-escaping="yes" on the xsl:text or xsl:value-of instructions may
work, but it doesn't always, for various reasons. It is considered a hack by
many its use is shunned by the old-timers on this list. The biggest problem
with it is that *if* it is supported at all (an XSLT processor is not required
to support it .. are you using Cocoon, perhaps? They intentionally disabled
it), it only applies to serialized output. If you are outputting a DOM (which
is what happens behind the scenes in Mozilla), there's no way to flag a text
node in the DOM as being in any way special.

Some XSLT processors have extensions that allow one to feed an arbitrary
string to a parser and get back a node-set or result tree fragment if the
parse goes OK. You could also write your own extension function/element to do
just that. Consult the docs for your processor for its API for writing
extensions.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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


Current Thread