CDATA output problem

Discussion in 'XML' started by ofuuzo1@yahoo.no, Feb 26, 2008.

  1. Guest

    I have an output xml doc that includes a CDATA section. The CDATA
    section is static. so my XSLT template looks something like;
    <xsl:stylesheet..>
    <xsl:template..>
    <![CDATA[<item1>]]>
    .....

    of course, there is some transformation in other parts of the
    document, but I need the CDATA section to simply be copied as text to
    the output doc. I have tried xsl:text, xsl:copy, but nothing seems to
    work, they all strip the CDATA and write out just

    &lt;item &gt;

    I need help.I am using php5 + dom.

    Thanks
    Ofuuzo
     
    , Feb 26, 2008
    #1
    1. Advertising

  2. As far as XML, and XSLT, are concerned <![CDATA[]]> markup is purely a
    syntactic detail.
    <![CDATA[<item1>]]>
    is semantically identical to
    &lt;item1&gt;
    and no XML-based application should ever care about the difference
    between them. XSLT discards that distinction during processing.

    If you're forced to deal with a broken application which does care about
    the difference, or if you're trying to be kind to inexperienced human
    readers. it is possible to explicitly tell XSLT that the text content of
    certain elements should be generated using <![CDATA[]]> syntax, via the
    cdata-section-elements property of the xsl:eek:utput element. For example,
    if you wanted the content of all <script> and <sample> elements to be
    output this way, your stylesheet could say:
    <xsl:eek:utput cdata-section-elements="sample script">
    (along with any other output directives, of course).

    CAVEAT: This is only a hint. XSLT is not required to honor this request,
    and even if it does so the next application you pass your XML data to
    may once again discard the distinction. The real "right answer" is to
    fix whatever downstream application is asking you to use CDATA Sections
    in the first place.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Feb 26, 2008
    #2
    1. Advertising

  3. Peter Flynn Guest

    wrote:
    > I have an output xml doc that includes a CDATA section. The CDATA
    > section is static. so my XSLT template looks something like;
    > <xsl:stylesheet..>
    > <xsl:template..>
    > <![CDATA[<item1>]]>
    > .....
    >
    > of course, there is some transformation in other parts of the
    > document, but I need the CDATA section to simply be copied as text to
    > the output doc. I have tried xsl:text, xsl:copy, but nothing seems to
    > work, they all strip the CDATA and write out just
    >
    > &lt;item &gt;
    >
    > I need help.I am using php5 + dom.


    http://xml.silmaril.ie/authors/cdata/

    ///Peter
     
    Peter Flynn, Feb 29, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Davison
    Replies:
    1
    Views:
    584
    Hal Rosser
    Jul 7, 2004
  2. Isaac Councill

    CDATA showing up at end of output files

    Isaac Councill, Jul 21, 2003, in forum: XML
    Replies:
    0
    Views:
    973
    Isaac Councill
    Jul 21, 2003
  3. Dimitre Novatchev

    .CDATA showing up at end of output files

    Dimitre Novatchev, Jul 21, 2003, in forum: XML
    Replies:
    0
    Views:
    1,197
    Dimitre Novatchev
    Jul 21, 2003
  4. Replies:
    3
    Views:
    757
    Joe Kesselman
    Mar 6, 2006
  5. werD
    Replies:
    4
    Views:
    13,526
Loading...

Share This Page