xsl-list
[Top] [All Lists]

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

2007-07-27 03:14:01
In addition to what's already been said, you may think of one of the
following two approaches of tackling this mess:

1. Using XSLT 2.0, you can replace any &lt; and &gt; that is inside
a text using a template like this together with a copy idiom:

<xsl:template match="text()[matches(., '&gt;|&lt;']" >
   <xsl:sequence select="translate(., '&gt;&lt;', '&EF00;&EF01')" />
</xsl:template>

and apply your character maps to the private use characters &EF00;
and &EF01; respectively.

2. Using a little bit more sophisticated replace and a function,
considering that only little tags (i.e., <b>, <i> <strong> etc) are
wrongly escaped that way, you can create your own saxon:parse
replacement with a regular expression + analyze-string (use both the
matching and non-matching part). I.e., you matching regex could be
something like this:

regex="&lt;([a-z]+)&gt;(.*)&lt;/\1&gt;"

which will capture the tagname in the $1 and the content between the
tags in $2.


Cheers,
-- Abel





Hello,

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

Is this possible? And how could it be done?

Grüße,

Kai Weber

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






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