Re: [xsl] 'Problems getting '&' output instead of '&'.

Subject: Re: [xsl] 'Problems getting '&' output instead of '&'.
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 6 Jan 2003 12:57:57 -0700 (MST)
Edward L. Knoll wrote:
> It's my second problem which is really bothering me.  We were doing our
> XML to HTML transformation in two passes: XML to XHTML, then XHTML to
> HTML (now being merged into a single pass for performance reasons).  The
> second pass transformation was a very simple transformation to remove
> the "html:" namespace prefixes from the tags and to have the XSLT
> processor output HTML instead of XML.  I modified the templates in this
> second stage transformation to disable-output-escaping when I output
> element attributes.  I would have thought this would cause the '&amp;'
> terms from the input XHTML to be transformed to '&' in the output HTML;
> it's not happening and I'm hoping someone can give me an explanation
> why.  I need a more complete understanding of when
> disable-output-escaping works and when it doesn't.

disable-output-escaping affects the serialization of text nodes only.
attributes are unaffected. Some XSLT processors offer a d-o-e extension
for attributes, but you can't count on it.

Your sample XML indicates that you're using script attributes like
onClick. An XSLT processor, when serializing the result tree with the
html output method, should be leaving script attributes and elements
unescaped. Is it possible that your XSLT processor is not doing this?
This should be easy enough to verify.

Also, a don't think a bare URL is a valid onClick value. I think you
need to put it inside a function call.

> p.s. Those with the "disable-output-escaping" chip on their shoulder
> leave the sermonizing behind.  I'm doing real work in the real word
> (e.g. in much less than ideal circumstances).

God, the irony. It is exactly those less-than-ideal circumstances (e.g.,
the fact that d-o-e only works in certain situations) that make
d-o-e a less-than-practical solution, as you have just discovered.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

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


Current Thread