XSL and CDATA section


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: XSL and CDATA section

  1. #1
    Mahesh Guest

    XSL and CDATA section


    Hi everyone,
    I have a xml doc with cdata section which contains html tags. I am using
    an xsl stylesheet to generate html output. I want that the html tags contained
    in my xml cdata section should not be escaped i.e. "<ul>" should remain as
    "<ul>", but I find that xsl transformation escapes these characters and what
    I get is "&lt;ul&gt;". I even tried disable-output-escape, but it still comes
    out the same. I tried with output mode both as html and xml.
    Any help on this will be highly appreciated.

  2. #2
    Rick Guest

    Re: XSL and CDATA section



    Mahesh -

    If <text> is the element containing your CDATA, try the
    following in your XSLT:

    <xsl:template match="text">
    <xsl:cdata>
    <xsl:value-of select="."/>
    </xsl:cdata>
    </xsl:template>

    Best of Luck,

    Rick



    "Mahesh" <mahesh_menghani@yahoo.com> wrote:
    >
    >Hi everyone,
    >I have a xml doc with cdata section which contains html tags. I am using
    >an xsl stylesheet to generate html output. I want that the html tags contained
    >in my xml cdata section should not be escaped i.e. "<ul>" should remain

    as
    >"<ul>", but I find that xsl transformation escapes these characters and

    what
    >I get is "<ul>". I even tried disable-output-escape, but it still comes
    >out the same. I tried with output mode both as html and xml.
    >Any help on this will be highly appreciated.



  3. #3
    Mahesh Guest

    Re: XSL and CDATA section


    "Rick" <rsteinberger@icmarc.org> wrote:
    >Hey Rick,

    Thanks for your response, but it didn't work guess since I am using .net
    xml.
    The problem appears only when
    I am using XSLTransform.transform method of .Net XML, but not with domdocument.transform
    method of MSXML4.


    I solved it by using <xslutput method="text"> instead of html.

    Thanks a lot,
    Mahesh
    >Mahesh -
    >
    >If <text> is the element containing your CDATA, try the
    >following in your XSLT:
    >
    ><xsl:template match="text">
    > <xsl:cdata>
    > <xsl:value-of select="."/>
    > </xsl:cdata>
    ></xsl:template>
    >
    >Best of Luck,
    >
    >Rick
    >
    >
    >
    >"Mahesh" <mahesh_menghani@yahoo.com> wrote:
    >>
    >>Hi everyone,
    >>I have a xml doc with cdata section which contains html tags. I am using
    >>an xsl stylesheet to generate html output. I want that the html tags contained
    >>in my xml cdata section should not be escaped i.e. "<ul>" should remain

    >as
    >>"<ul>", but I find that xsl transformation escapes these characters and

    >what
    >>I get is "<ul>". I even tried disable-output-escape, but it still comes
    >>out the same. I tried with output mode both as html and xml.
    >>Any help on this will be highly appreciated.

    >



  4. #4
    Jason Guest

    Re: XSL and CDATA section


    > I solved it by using <xslutput method="text"> instead of html.


    What if you don't specify the "method" attribute? That should output well
    formed XML. If you specify "HTML," that is trying to put out well formed
    HTML, which is NOT well formed XML.


  5. #5
    Join Date
    Jul 2008
    Posts
    1
    Why don't you try the property cdata-section-elements ="your element name" inside <xslutput ? it worked for me

    Quote Originally Posted by Jason

    > I solved it by using <xslutput method="text"> instead of html.


    What if you don't specify the "method" attribute? That should output well
    formed XML. If you specify "HTML," that is trying to put out well formed
    HTML, which is NOT well formed XML.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center