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

RE: grouping headers

Subject: RE: grouping headers
From: "Corey Spitzer" <cspitzer@xxxxxxxxx>
Date: Thu, 23 Aug 2001 17:13:13 -0500
xsl hard return

first, you'll want to alphabetize the list based on city name so run this
stylesheet on the xml:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="people">
  <people>
  <xsl:apply-templates select="person"><xsl:sort
select="city"/></xsl:apply-templates>
  </people>
</xsl:template>

<xsl:template match="person">
	<person>
	<city><xsl:value-of select="city"/></city>
	<name><xsl:value-of select="name"/></name>
</person>
</xsl:template>

</xsl:stylesheet>

Then, do this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="people">

  <xsl:apply-templates select="person"/>

</xsl:template>

<xsl:template match="person">

<xsl:if test="not(preceding-sibling::person[1]/city=city)">

  <xsl:text disable-output-escaping="yes">
</xsl:text> <!-- hard return to make it look pretty -->

  <xsl:value-of select="city"/>

  <xsl:text disable-output-escaping="yes">
</xsl:text> <!-- hard return to make it look pretty -->

</xsl:if>

<xsl:value-of select="name"/>

<xsl:text disable-output-escaping="yes">
</xsl:text> <!-- hard return to make it look pretty -->

</xsl:template>

</xsl:stylesheet>









-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jeroen
Janssen
Sent: Thursday, August 23, 2001 4:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  grouping headers


Sorry for the subject line, I couldn't think of anything better :-) I'm
trying to do the following:

I have something like this xml:

<people>
    <person>
        <city>Amsterdam</city>
        <name>John Doe</name>
    </person>

    <person>
        <city>Amsterdam</city>
        <name>Jane Doe</name>
    </person>

    <person>
        <city>London</city>
        <name>Jim Doe</name>
    </person>
</people>

And would like this result in html:

Amsterdam
John Doe
Jane Doe

London
Jim Doe

I hope I'm making myself clear, I searched the archives for an answer but I
don't really know what I'm looking for...




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


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