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

Re: Displaying Unique attribute value

Subject: Re: Displaying Unique attribute value
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Fri, 3 Oct 2008 14:19:53 +0100
Re:  Displaying Unique attribute value
2008/10/3 Ganesh Babu N <nbabuganesh@xxxxxxxxx>:
> 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.
>

Use a key:

<xsl:key names="page-nums" match="*" use="@page-num"/>

with

<xsl:if test="generate-id() = generate-id(key('page-nums', @page-num)[1])">

to test if that element has the first first occurrence of its page-num attribute


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.