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

Re: Sorting and grouping unknown elements

Subject: Re: Sorting and grouping unknown elements
From: "Claus Jessing" <claus@xxxxxxxxxx>
Date: Mon, 24 Sep 2007 08:53:01 +0200
Re:  Sorting and grouping unknown elements
Thanks David

Couldn't get your first example to work. I'm using javax.xml.transform
for the actual transformation and Eclipse tells me that for-each-group
is an unkown xsl element.

Your other example works just fine tho :-)

Thanks

Claus Jessing

On 9/21/07, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>
> oops I grouped the wrong thing, try
>
> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:output indent="yes"/>
>   <xsl:template match="rowset">
>     <xsl:for-each-group select="row/*" group-by="name()">
>       <xsl:sort select="name()"/>
>       <select name="{current-grouping-key()}">
>         <xsl:for-each-group select="current-group()" group-by=".">
>           <xsl:sort/>
>           <option><xsl:value-of select="."/></option>
>         </xsl:for-each-group>
>       </select>
>     </xsl:for-each-group>
>   </xsl:template>
> </xsl:stylesheet>
>
> $ saxon8 rs.xml rs2.xsl
> <?xml version="1.0" encoding="UTF-8"?>
> <select name="color">
>    <option>Blue</option>
>    <option>Red</option>
> </select>
> <select name="make">
>    <option>Toyota</option>
> </select>
> <select name="model">
>    <option>Corolla</option>
>    <option>Yaris</option>
> </select>
>
>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:output indent="yes"/>
>   <xsl:key  name="n" match="*" use="name()"/>
>   <xsl:key  name="v" match="*" use="concat(name(),.)"/>
>   <xsl:template match="rowset">
>     <xsl:for-each select="row/*[generate-id(.)=generate-id(key('n',name()))]">
>       <xsl:sort select="name()"/>
>       <select name="{name()}">
>         <xsl:for-each select="../../row/*[generate-id(.)=generate-id(key('v',concat(name(current()),.)))]">
>           <xsl:sort/>
>           <option><xsl:value-of select="."/></option>
>         </xsl:for-each>
>       </select>
>     </xsl:for-each>
>   </xsl:template>
> </xsl:stylesheet>
>
>
> $ saxon rs.xml rs1.xsl
> <?xml version="1.0" encoding="utf-8"?>
> <select name="color">
>    <option>Blue</option>
>    <option>Red</option>
> </select>
> <select name="make">
>    <option>Toyota</option>
> </select>
> <select name="model">
>    <option>Corolla</option>
>    <option>Yaris</option>
> </select>
>
>
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________
>
>



-- 
Claus Jessing, jessing.dk
---------------------------------------------
M: +45 6061 0101, P: +45 4461 0101
E: claus@xxxxxxxxxx, IM: claus@xxxxxxxxxx

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.