xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 18 Jul 2011 14:13:14 +0200

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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor