Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:47 AM
matatu
Guest
 
Posts: n/a
Default &lt; to < with XSLT

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
  #2  
Old July 20th, 2005, 08:47 AM
David Carlisle
Guest
 
Posts: n/a
Default Re: &lt; to < with XSLT


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
  #3  
Old July 20th, 2005, 08:47 AM
matatu
Guest
 
Posts: n/a
Default Re: &lt; to < with XSLT

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:
[color=blue]
> 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[/color]
  #4  
Old July 20th, 2005, 08:47 AM
David Carlisle
Guest
 
Posts: n/a
Default Re: &lt; to < with XSLT


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
  #5  
Old July 20th, 2005, 08:47 AM
Richard Tobin
Guest
 
Posts: n/a
Default Re: &lt; to < with XSLT

In article <cl5l75$d90$1@lacerta.tiscalinet.it>,
matatu <mar0as@katamail.com> wrote:
[color=blue]
>thankes for your answer, but it' not possible for me because if I have
>an other &lt; it must be no converted... example:[/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles