RE: dealing with CDATA (was dealing with CDATA on the client-side)

Subject: RE: dealing with CDATA (was dealing with CDATA on the client-side)
From: "Paulo Gaspar" <paulo.gaspar@xxxxxxxxxxxx>
Date: Wed, 7 Jun 2000 14:54:14 +0200
Use something like:
  <xsl:value-of select="etcetera" disable-output-escaping="yes" />

This works with MSXML3, May 2000 release.


Answer by example:

XML File:

<?xml version="1.0" encoding="ISO-8859-1"?>
<main>
<etcetera>
    <![CDATA[this is a <a href="http://yahoo.com>test link/a>]]>
</etcetera>
</main>

XSL File:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >

    <xsl:output method="xml" indent="yes" encoding="ISO-8859-1" />

  <xsl:template match="/">
    <xsl:apply-templates select="*" />
  </xsl:template>

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

</xsl:stylesheet>


Result:

<?xml version="1.0" encoding="ISO-8859-1"?>
<etcetera>
    this is a <a href="http://yahoo.com>test link/a>
</etcetera>


Have fun,

Paulo
(paulo.gaspar@xxxxxxxxxxxx)



> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Eric Costello
> Sent: Tuesday, June 06, 2000 20:29
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: dealing with CDATA (was dealing with CDATA on the client-side)
>
>
> Hello all,
>
> First time poster here.
>
> SYNOPSIS:
> What do I need to do to keep an XSL transform in an MS XMLDOM environment
> from converting < and > in a CDATA node to &lt; and &gt;?
>
> DETAILS:
> Using Microsoft's XMLDOM object on the server side to transform
> an XML file
> with an XSL file and output HTML to the browser, I run into the
> same problem
> as Matt Haughey: CDATA comes through the transform with < and >
> converted to
> &lt; and &gt;. Here is the relevant section of his previous post to this
> list (which mentions a client side occurrence of this problem, but the
> problem is identical on the server):
>
> -----------------------------------------------
> <etcetera>
>     <![CDATA[this is a <a href="http://yahoo.com>test link/a>]]>
> </etcetera>
>
> applying XSL on the client-side leaves unparsed HTML sitting in the text,
> so it looks like this in a browser:
>
> this is a <a href="http://yahoo.com>test link/a>
>
> instead of
>
> this is a test link  (test link being a hyperlink to yahoo in
> this example)
>
> Now to get around this, on the server-side, we've been doing search and
> replaces on &lt; and &gt; characters, and replacing them with < and > to
> produce parse-able HTML when sent to the client.
> ------------------------------------------------
>
> Replacing the &lt; and &gt; characters with < and > is a solution
> that I am
> using along with Matt, but it seems pretty kludgey to me. IS
> there something
> I should be doing in my code that would preserve the characters
> as they are
> in the CDATA? Or is this normal and uncorrectable behavior that I need to
> code around?
>
> Thanks,
> Eric
>
> Eric Costello
> eric@xxxxxxxxx
> http://glish.com
>


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


Current Thread