[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Displaying element value in browser, which is insi

Subject: Re: Displaying element value in browser, which is inside CDATA in XML
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 18 Jul 2011 14:13:14 +0200
Re:  Displaying element value in browser
Ramkumar V wrote:

I used the same template match, to display anchor attribute('name') value in
browser. But I can't.

XSL:
====
<xsl:template match="bk:text">
  <p><xsl:value-of select="." disable-output-escaping="yes"/></p>
</xsl:template>

<xsl:template match="a">
<xsl:apply-templates/><sup><font color="red"><xsl:value-of
select="@name"/></font></sup>
</xsl:template>

XML:
====
<?xml version="1.0"?>

<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>

Required Browser output:
========================
Psychologists acknowledge that, as in the heroism of Sully
  Sullenberger, sometimes an individual&#8217;s best moments emerge
<<  the text 'page7' will appear superscript and font color :red>>
amid the most difficult
  circumstances

Well if the markup in the input XML is contained in a CDATA section then in the XSLT/XPath data model there is simply a text node as the sole child node of the 'bk:text' element. If you want to use XPath or apply-templates on the XML markup in that text node then you first need to parse the markup as XML (as long as it is XML). However doing so requires an extension function. Saxon 9 has one for such a task
<xsl:template match="bk:text"
<p>
<xsl:apply-templates select="saxon:parse(concat('&lt;dummy&gt;', ., '&lt;/dummy&gt;'))/dummy/node()"
xmlns:saxon="http://saxon.sf.net/"/>
</p>
</xsl:template>



--


	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.