xsl-list
[Top] [All Lists]

RE: [xsl] for-each-group

2007-03-27 12:35:44
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:strip-space elements="*" />
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

    <xsl:template match="/">
        <xsl:apply-templates />
    </xsl:template>

        <xsl:template match="products">
                <products>
                <xsl:for-each-group select="product" group-by=".">
                  <product><xsl:value-of select="." /></product>
                </xsl:for-each-group>
                </products>
        </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Robert C Corsaro <rcorsaro(_at_)optaros(_dot_)com>
Sent:     Tue, 27 Mar 2007 14:24:48 -0500
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] for-each-group

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to transform the following XML:

<products>
  <product>1</product>
  <product>1</product>
  <product>1</product>
  <product>1</product>
  <product>1</product>
  <product>1</product>
  <product>1</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
  <product>2</product>
</products>

to:

<products>
  <product>1</product>
  <product>2</product>
</products>

using:

<products>
<xsl:for-each-group select="/products" group-by="product">
  <product><xsl:value-of select="product" /></product>
</xsl:for-each-group>
</products>

What am I doing wrong?  Basically I want something similar to 'GROUP BY'
 in SQL.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGCW+AkAu83kdgE3MRArfOAKCu2SzjWaqQt9GtHt7N/XielwUCZACdGHSg
YKXjGT0JUVuxEcc/ntWPInI =qeAN
-----END PGP SIGNATURE-----

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>