|
Subject: Re: [xsl] Displaying Unique attribute value From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Fri, 3 Oct 2008 14:19:53 +0100 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Displaying Unique attribute v, Ganesh Babu N | Thread | Re: [xsl] Displaying Unique attribu, David Carlisle |
| [xsl] Displaying Unique attribute v, Ganesh Babu N | Date | Re: [xsl] Displaying Unique attribu, David Carlisle |
| Month |