RE: [xsl] &lt; to < while preserving &amp;

Subject: RE: [xsl] &lt; to < while preserving &amp;
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 26 Jul 2007 17:13:20 +0100
> <title>Me &amp; You &lt;i&gt;together&lt;/i&gt;</title>
> 
> I tried my best with character-maps to get from the above XML 
> the following HTML:
> 
> <h3>Me &amp; You <i>together</i></h3>
> 

Character maps aren't going to help you.

In general the way to get from a "<" character to an element node, or from
an &lt; entity reference to a "<" character, is by parsing. You need to take
the content of your title element and put it through an XML parser, for
example by using saxon:parse.

But you can't do that because it will fail at the & character.

You've got a dirty mess here, and like all data cleansing operations, the
strategy depends on discovering the extent of the mess. If this title
element is the sum total of your data, or the only part that's dirty, then
edit it by hand. If it's part of a much larger mess, then we need a bigger
picture as to what other horrors it contains.

And of course the other part of data cleansing is to work out where the bad
data came from and to stop it happening again.

Michael Kay
http://www.saxonica.com/

Current Thread