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

Displaying Unique attribute value

Subject: Displaying Unique attribute value
From: "Ganesh Babu N" <nbabuganesh@xxxxxxxxx>
Date: Fri, 3 Oct 2008 18:42:42 +0530
 Displaying Unique attribute value
Dear All,

I am having a tricky XML which i have to view in IE using XSL. (As IE
does not support XSLT 2.0), the solution should be in XSLT 1.0

My XML is like below:

<chapter id="i120" page-num="1" extra-info="CHAPTER 1">
	<title id="i121" page-num="1">Introduction to Corporate Finance</title>
	<chbeginning id="i122" page-num="1" extra-info="Chapter Opener">
		<title id="i123" page-num="1">OPENING CASE</title>
		<para id="i124" page-num="1" dropcap="yes">Apple began as a
two-man....million.</para>
		<para id="i125" page-num="1">Despite...altogether.</para>
		<para id="i126" page-num="1">Of course... Steven Jobs!</para>
		<para id="i127" page-num="1">With ... 74 days.</para>
	</chbeginning>
	<chbody id="i128" page-num="1" extra-info="Chapter Body">
		<section id="i129" page-num="1">
			<title id="i130" page-num="1">1.1 WHAT IS CORPORATE FINANCE?</title>
			<sectbody id="i131" page-num="1">
				<para id="i132" page-num="1">Suppose... firm.</para>
				<subsection id="i133" page-num="2">
					<title id="i134" page-num="2">The Balanc.. Firm</title>
					<para id="i135" page-num="2">Suppose ... finance.</para>


In the above XML, page-num attribute is there for all the elements. My
requirement is that to display the value of the page-num attribute
only first time. Means i should display the page-num at where the
value is changing. We don't know on which node the value will change
it may be child, it may be sibling.


I have used the following code in the root template to achieve this
action but failed.


<xsl:template match="/">
<xsl:for-each select="@page-num">
<xsl:if test="self::*/@page-num !=
following::*/@page-num"><xsl:value-of
select="current()/@page-num"/></xsl:if>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:template>

Please guide me where I am going wrong.

Regards,
Ganesh

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.