xsl-list
[Top] [All Lists]

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

2007-07-26 09:16:11
 

<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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>