Re: [xsl] Displaying element value in browser, which is inside CDATA in XML

Subject: Re: [xsl] Displaying element value in browser, which is inside CDATA in XML
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 18 Jul 2011 15:08:35 +0100
On 18/07/2011 12:41, Ramkumar V wrote:
Hi, List

I want to display anchor element attribute value in browser, but it is in
CDATA.

There is no anchor element in your CDATA. If the CDATA markup were absent, there would be an anchor element, but CDATA means "character data", and its purpose is to say "the thing in here might look like an anchor element, but it isn't really, it's just ordinary text".


So, by including the CDATA markup, you have told the XML parser not to treat the <a>..</a> as an element. Your only remedy now is to extract the text of the CDATA and parse it again. You can't do this in standard XSLT, but you can do it with the help of an extension such as saxon:parse().

If the content of your CDATA section is HTML, and you want it copied directly to the output, then you can sometimes achieve this using disable-output-escaping, but whether this works or not depends on your XSLT processor and the way you are running it.

Michael Kay
Saxonica
Please suggest anyone how to display this value?

SAMPLE XML
==========

<a class="page_break" name="page7"></a>

<bk:text><![CDATA[Psychologists acknowledge that, as in the heroism of Sully
Sullenberger, sometimes an individual&#8217;s best moments emerge<a
class="page_break" name="page7"></a>  amid the most difficult
circumstances.]]></bk:text>

Regards,
Ramkumar V



===========================================================
***Disclaimer***


This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by the company. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. The company does not accept liability for damage caused by any of the foregoing.


ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY.
============================================================

Current Thread