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

Re: AW: XPATH restricting preceding nodes

Subject: Re: AW: XPATH restricting preceding nodes
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Sep 2003 09:39:51 -0400
erwin xml
At 2003-09-10 14:45 +0200, Kloeck, Erwin wrote:
your solution works. This was what I needed. Now I have to read a little about what xls:key does to also understand this. :-)

Actually, when doing subgrouping on a tree you don't *always* have to use keys.


When I teach grouping in XSLT 1.0 I go through three different methods: by axes, by variables and by keys. I find that multi-level grouping or subgrouping can be a lot easier by variables when you don't need to act on node sets.

But I also go over keys as a standalone concept, not just in grouping ... a week from Monday we have a public European delivery of our courses that you might be interested in where we go over every element, attribute and function of both XSLT and XPath, and in a separate course that week, every formatting object of XSL-FO.

I hope the example below helps.

.................... Ken

T:\ftemp>type erwin.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<top>
        <page>
                <entry text='aaa'/>
                <entry text='bbb'/>
                <entry text='aaa'/>
        </page>
        <page>
                <entry text='ccc'/>
                <entry text='bbb'/>
                <entry text='ccc'/>
        </page>
</top>

T:\ftemp>type erwin.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="text"/>

<xsl:template match="top">
<xsl:for-each select="page">
Page <xsl:value-of select="position()"/>:
<xsl:variable name="entries" select="entry"/>
<xsl:for-each select="$entries">
<xsl:if test="generate-id(.)=generate-id($entries[@text=current()/@text])">
Entry: <xsl:value-of select="@text"/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>
T:\ftemp>saxon erwin.xml erwin.xsl

Page 1:

      Entry: aaa
      Entry: bbb
    Page 2:

      Entry: ccc
      Entry: bbb
T:\ftemp>


-- Next public European delivery: 3-day XSLT/2-day XSL-FO 2003-09-22 Next public US delivery: 3-day XSLT/2-day XSL-FO 2003-10-13 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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-2011 All Rights Reserved.