<xsl:output> has an optional attribute called cdata-section-elements. See http://www.w3.org/TR/xslt#element-output
This would require that you explicitly list the element qnames whose text content you want treated this way, and it's applied to every instance of those elements. You must know in advance which kinds of elements would need to be treated this way. Sorry, but it doesn't accept match patterns or wildcards, only qnames, so an "identity transformation with CDATA sections" is not supported. If the latter is really what you need, I'd suggest you have the XSLT processor produce SAX events as output, and hook in your own serializer which has been wrapped with a filter which causes all text nodes to be written out in this form. You'd still get the benefits of XSLT for other document processing tasks. ______________________________________ "You build world of steel and stone I build worlds of words alone Skilled tradespeople, long years taught: You shape matter; I shape thought." (http://www.songworm.com/lyrics/songworm-parody/ShapesofShadow.html) From: ajay bhadauria <abhadau...@yahoo.com> To: xalan-j-users@xml.apache.org, Date: 11/17/2011 09:26 AM Subject: Re: Need to copy all the cdata elements to output xml using xslt Thanks a lot for reply, I agree with you. However, in our case, the other side of the legacy application expects all element with CDATA section. So, If I need to get all the CDATA section in the output xml, what should I do in the xslt where I do not know which elements have CDATA but I need all the elements in the output. Regards Ajay --- On Thu, 11/17/11, kesh...@us.ibm.com <kesh...@us.ibm.com> wrote: From: kesh...@us.ibm.com <kesh...@us.ibm.com> Subject: Re: Need to copy all the cdata elements to output xml using xslt To: "ajay bhadauria" <abhadau...@yahoo.com> Cc: xalan-j-users@xml.apache.org Date: Thursday, November 17, 2011, 10:37 AM Semantically, there is no difference between text within a CData Section and other text (possibly with characters escaped as Numeric Character References). It's only a matter of how you happened to express that particular value in the file. In particular, the XML Data Model doesn't distinguish between these, the XPath Data Model doesn't distinguish between these, and hence XSLT doesn't distinguish between these. So: Don't worry about it. Let the parser and serializer deal with this, rather than trying to preserve the specific CData Section markup. The output may not look the same as the input, but will be semantically identical for any properly-written XML application. If you know that specific elements do want their content expressed as CData Sections, XSLT does provide a way to express that hint. But if you don't know that in advance, you probably don't need to know it at all. ______________________________________ "You build world of steel and stone I build worlds of words alone Skilled tradespeople, long years taught: You shape matter; I shape thought." (http://www.songworm.com/lyrics/songworm-parody/ShapesofShadow.html) From: ajay bhadauria <abhadau...@yahoo.com> To: xalan-j-users@xml.apache.org, Date: 11/17/2011 12:00 AM Subject: Need to copy all the cdata elements to output xml using xslt Hi, I need to copy all the elements including cdata element of a parent element. I do not know that which child element is going to have cdata element however I need to copy all the children to output xml file using xslt. Is there any we can do that ? Any help will be great. My XML file is <SwInt:RequestPayload xmlns:SwInt="abc.txt"> <SwInt:firstName>Robert</SwInt:firstName> <SwInt:lastName>Dowson</SwInt:lastName> <SwInt:address>Nokesville</SwInt:address> <SwInt:Data><![CDATA[aaaaa<>]]></SwInt:Data> <SwInt:Data1>aaaaa<></SwInt:Data1> </SwInt:RequestPayload> Regards Ajay