Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > CDATA output problem

Reply
Thread Tools

CDATA output problem

 
 
ofuuzo1@yahoo.no
Guest
Posts: n/a
 
      02-26-2008
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
 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      02-26-2008
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 xslutput element. For example,
if you wanted the content of all <script> and <sample> elements to be
output this way, your stylesheet could say:
<xslutput 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
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      02-29-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:output cdata-section-elements werD XML 4 08-28-2006 03:04 AM
Can I un-CDATA my CDATA section and elaborate a transformation for the contained data? troppfigo@excite.it XML 3 03-06-2006 03:01 AM
Extracting CDATA Text without CDATA Tags??? John Davison Java 1 07-06-2004 11:00 PM
.CDATA showing up at end of output files Dimitre Novatchev XML 0 07-21-2003 07:48 AM
CDATA showing up at end of output files Isaac Councill XML 0 07-21-2003 05:28 AM



Advertisments