Re: [xsl] include html code from xml

Subject: Re: [xsl] include html code from xml
From: longjohn <longjohn@xxxxxxxxxxxx>
Date: Thu, 09 May 2002 19:15:46 +0200
I'm sorry , I'm very tired and I made many mistakes !
I've made a very simple example (full of errors) , but the problem is that I want to include :


<a href= "http://www.polito.it"; class="norm" target="_top">Politecnico di Torino</a>
<br /><a href= "http://www.polito.it/dipartim/autoinfo/itindex.html"; class="norm" target="_top">
Dipartimento di Automatica e Informatica</a><br />Corso Duca degli Abruzzi 24 <br />


My output has to be:
Politecnico di Torino
Corso Duca degli Abruzzi 24

instead i obtain :
<a....... <br/>

Can you give me a schematic example of a stylesheet that could do this using <xsl:call-template ...> ?
Thanks





David Carlisle wrote:


I've got an XML tag containing some html code as a string.


<TAG1> hello<br>bye </TAG1>


Be careful with teh terminology: hello<br>bye is not contained in any tag, the start tag <TAG1> just contains the element name TAG1 (and no attributes in this case) similarly the end tag </TAG1> just contains the element name TAG1.

Your HTML is contained in the element TAG1 (which is marked with two
tags, a start tag and and end tag: don't confuse "tag" with "element"
otherwise you will be very confused using XSLT (and XML, generally).

Ypu can not have what you say you have as otherwise your document is not
well formed and the only thing you get is a fatal parse error.

If your HTML is coded as well formed XML

eg

<TAG1> hello<br/>bye </TAG1>
              ^
Then you are in a good situation and you can just do

<xsl:copy-of select="."/>

However i suspect you have

<TAG1><![CDATA[ hello<br>bye ]]></TAG1&g
t;
or equivalently
<TAG1> hello&lt;br>bye </TAG1>

By far the best plan is to make sure that your XML is _not_ in this form
but in the first form, but failing that you can resort to using
disable-output-encoding="yes"
if you are in a situation where this is supported, but that is only an
escape to be used as a last resort.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


<
/pre>




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread