[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Processing XML with multiple nested CDATA sections


Subject: Re: [xsl] Processing XML with multiple nested CDATA sections
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 01 Mar 2013 00:04:56 +0000

On 28/02/2013 23:47, dvint@xxxxxxxxx wrote:
  Some of
these CDATA sections have CDATA sections in them.

You can't nest CDATA sections.


<![CDATA[a <![CDATA[b ]]> c ]]>

is a fatal syntax error as the CDATA section ends at the first ]]>
so the second ]]> is a syntax error. The second <![CDATA[ doesn't start a CDATA section at all as it is equivalent to &lt;![CDATA[.


In your example the inner "]]>" is changed to ]] > to avoid this.

The input is a mess and this isn't guaranteed to work but on the posted example



<xsl:template match="hibernate-generic">
<xsl:value-of disable-output-escaping="yes" select="replace(object/property[@name='body'],'(&lt;!\[CDATA\[)|(\]\] *>)','')"/>
</xsl:template>


produces


<p>Creating Inted.</p><p>You can also ptions.</p> <h1>Generating</h1><p><ac:link><ri:page ri:content-title="Types of Widgets" /><ac:plain-text-link-body>Infographic widgets </ac:plain-text-link-body></ac:link> are ways.</p>


David



Current Thread