Re: Suppressing character entity transformation



R. P. wrote:
"Joe Kesselman" <keshlam-nospam@xxxxxxxxxxx> wrote:
(Sigh. In the past I've mostly ignored this sort of editing glitch.

I'm not sure what you're getting at.

I was gently chastizing Pavel for a minor stylistic point. Nothing to do with you.

I'm still not understanding what problem you're having. When XSLT reads in a document, character references and entity references are expanded; when it writes the document back out as either XML or HTML, it should re-create character references where (and only where) they're necessary.

If your output mode is Text, other rules apply. If you're taking SAX or DOM output from the XSLT processor and converting it to characters via your own serializer code, then it's your responsibility to make sure this is handled properly.

> Note the '&' in the RELEASE_STATEMENT.

As Pavel said, your style*** is REALLY badly designed. You should ***NEVER*** be trying to hand-construct tags. Doing so will at best rob you of some of the strength of XSLT and force you to do lots of unnecessary work, and at worst may seriously confuse the next stage of processing. You really want to fix that, along the lines he illustrated (issuing actual elements rather than text that looks like tags) before you do anything else.

In fact, it is precisely because you *have* forced the hand-construction of tags that the & isn't getting converted back to &amp;. If you're outputting text, the processor just writes out the characters. You need to tell it that you're producing XML if you want it to convert characters as necessary for XML.

In fact, that's precisely why setting output to XML was giving you &#60; in place of < -- because < is a reserved character, and has to be escaped. (&#60; is equivalent to &lt;, just as &#38; is equivalent to &amp;).

Set output to XML mode. Replace your hand-constructed tags with real XML structure. The result may not be *exactly* what you expect -- you may get the &38; rather than &amp; -- but it will be correct. Trying to make the kluge you've got now do the right thing really is a lost cause; it may not be possible, and it certainly isn't worth the effort.


You may or may not like that advice. But it's the correct advice.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
.


Loading