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

RE: Urgent: Grouping attributes together

Subject: RE: Urgent: Grouping attributes together
From: Jarkko Moilanen <Jarkko.Moilanen@xxxxxx>
Date: Wed, 18 Jun 2003 09:55:39 +0300 (EEST)
student section cheers
On Wed, 18 Jun 2003 Jarno.Elovirta@xxxxxxxxx wrote:

> FFFAQ,
>
> > I need help to write an XSLT file for converting first.xml to
> > second.xml
> > where the attribute values are grouped
>
> Did you have a look at the FAQ or Jeni's pages on grouping?
>
>   <xsl:key name="class" match="student" use="@class"/>
>   <xsl:template match="school">
>     <xsl:copy>
>       <xsl:for-each select="student[generate-id(.) = generate-id(key('class', @class))]">

I would replace this:
>         <Section class="A">

to  <Section class="{@class}">

>           <xsl:apply-templates select="key('class', @class)"/>
>         </Section>
>       </xsl:for-each>
>     </xsl:copy>
>   </xsl:template>
>   <xsl:template match="student/@class"/>
>   <xsl:template match="@* | node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@* | node()"/>
>     </xsl:copy>
>   </xsl:template>
>

Result:
<?xml version="1.0"?>
<school>
  <Section class="A">
    <student>L</student>
    <student>O</student>
    <student>S</student>
  </Section>
  <Section class="B">
    <student>M</student>
    <student>Q</student>
  </Section>
  <Section class="C">
    <student>P</student>
    <student>R</student>
  </Section>
</school>

Cheers,
Jarkko

****************************************************************
Jarkko Moilanen          "Erehtyminen on inhimillista,
Researcher                mutta todella suuret mokat
jm60697@xxxxxx            vaativat tietokoneen käyttöä."
www.uta.fi/~jm60697
GSM: +358 50 3766 927
****************************************************************
* ITCM | Information Technology and Crisis Management
* http://www.itcm.org
****************************************************************






 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.