[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: copying CDATA section from xml
NILESH PATEL wrote: > I have a small xml document which basically containes standard output by > running native command on java and it only containes simple text in CDATA > section as shown below in XML. However I don't know how to write xsl to grab > all the details of CDATA section and write out in text format. Please help. > If any questions then please let me know. Looking forward to resolve this. CDATA sections are a convenience for document authors only; their only purpose is to make it so you don't have to escape "<" and "&" characters. They are not a part of the XPath/XSLT data model. All character data, whether it is in a CDATA section or not, gets merged into text nodes in a node tree. For example, <foo>1 <![CDATA[& 2 are <]]> 3</foo> becomes two nodes: element 'foo' | |___text '1 & 2 are < 3' So your question is simply, how do you copy the the text content of your 'stdout' element. Easy: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="iso-8859-1"/> <xsl:template match="/"> <xsl:value-of select="root/stdout"/> </xsl:template> </xsl:stylesheet> - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|