Subject: Re: [xsl] NEW2!!!showing HTML data in XML files using XSL!!! From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 6 Apr 2001 09:12:56 +0100 |
Hi Rosa, > what if the HTML text is between <![CDATA[text is <I>here</I>]]> in > the XML file? how can I copy that section and display as HTML > normally. Cos at the moment, I get something like this: text is > <I>here</I> on the browser, the XSL seem to have changed the '<' and > '>' into < and > The text: <![CDATA[text is <I>here</I>]]> is *exactly* the same as: text is <I>here</I> and as: text is <I>here</I> and as: textis<I>here</I> and so on. CDATA sections are ways of storing text information without having to bother with escaping less-than signs and ampersands. To an XSLT processor, anything within them is just text - it doesn't recognise any XML syntax within it. So it's not the XSLT processor changing the '<' into < - you gave it a less-than character in the first place, with <![CDATA[<]]> or with <. The best thing to do is to change the source so that rather than giving a text string, you give it the mixed content (text and elements) that you want it to have. So use: text is <I>here</I> No CDATA section, no escaping of less-than signs - here a '<' means the start of a tag, not the character '<'. So the above is a text node, followed by an I element. If you copy that, then you will get the text node and the I element in your result, as you want: <xsl:copy-of select="root/text/node()" /> If you absolutely *cannot* change the XML source, then you are stuck with disable-output-escaping. In those processors that support it, you can use disable-output-escaping to copy a text string into the output, without having the processor check the text string at all to replace those characters that need escaping. So you could use: <xsl:value-of disable-output-escaping="yes" select="root/text" /> But I wouldn't recommend it because it bypasses all the work that the XSLT processor does for you in making sure that the output is correct. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] NEW2!!!showing HTML data , David Carlisle | Thread | RE: [xsl] NEW2!!!showing HTML data , Michael Kay |
Re: [xsl] MSXML, xsl:copy, XML Outp, Jeni Tennison | Date | RE: [xsl] MSXML, xsl:copy, XML Outp, Paul Hammond |
Month |