By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,763 Members | 1,641 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,763 IT Pros & Developers. It's quick & easy.

&lt; to < with XSLT

P: n/a
Hi to all,

I have a xml file, a substring like:

&lt;a href=&quot;#&quot;&gt;text&lt;/a&gt;

which after an xslt trasform is rendered as (using xsl:output method html):

&lt;a href="#"&gt;text&lt;/a&gt;
How can I get as xslt result the following:

<a href="#">text</a>

I cannot use CDATA for indexing problem of the original text...

thank you for any suggestion
Mark
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

If your processor supports d-o-e then you can use

<xsl:value-of disable-output-escaping="yes" select="."/>

assuming the current node is the element containing your quoted string.

David
Jul 20 '05 #2

P: n/a
Hi David,
thankes for your answer, but it' not possible for me because if I have
an other &lt; it must be no converted... example:

text 3&lt;4 is true as shown in the following url:
&lt;a href=&quot;#&quot;&gt;text&lt;/a&gt;

in which the first "&lt;" must be not converted before it arrives to the
browser, others they do...

David Carlisle ha scritto:
If your processor supports d-o-e then you can use

<xsl:value-of disable-output-escaping="yes" select="."/>

assuming the current node is the element containing your quoted string.

David

Jul 20 '05 #3

P: n/a

grr

If possible I'd suggest not starting from there, your input is basically
broken, but if you have no control over the input then basically what
you need to do is decide on some heuristics that some piece of text
"looks like" HTML markup and so output it unquoted.

I really wouldn't use XSLT 1 for that, you want something with regexp
support, perl or XSLT2 draft (as implemented in saxon 8) or if you are
using xslt1 I'd look into whether your processor allows extension to
some language with regexp (javascript or java perhaps) just to handle
that text string.

In simple cases you could use
<xsl:value-of select="substring-before('.&lt;a href=&quot;')/>
<a href="{substring-before(substring-after('.&lt;a href'),'&quot;')}">

etc etc with lots of substring before and after, but it gets very hard
to manage such code.

David
Jul 20 '05 #4

P: n/a
In article <cl**********@lacerta.tiscalinet.it>,
matatu <ma****@katamail.com> wrote:
thankes for your answer, but it' not possible for me because if I have
an other &lt; it must be no converted... example:


Well, how do you expect XSLT to know which should be converted? Only
you know that! You will have to make your stylesheet disable output
escaping for the ones that need to be converted, and not for the
others.

It may well be that XSLT is not the best tool for this; a generic
stream editor like sed might be better. Or perhaps you should
reconsider how your data is generated in the first place, so that it
doesn't have markup represented in the same way as ordinary text.

-- Richard
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.