[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] help on removing duplicates


Subject: [xsl] help on removing duplicates
From: juan valentín-pastrana <jvalentin@xxxxxxxxxx>
Date: Thu, 20 Jan 2005 22:34:54 +0100

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

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


out of this xml:
<xml>
  <el>
    <node>A</node>
    <rel>
      <el>
        <node>X</node>
        <obj>myobject</obj>
      </el>
    </rel>
  </el>
  <el>
    <node>A</node>
    <rel>
      <el>
        <node>X</node>
        <obj>myobject</obj>
      </el>
    </rel>
  </el>
  <el>
    <node>A</node>
    <rel>
      <el>
        <node>Y</node>
        <obj>myobject</obj>
      </el>
    </rel>
  </el>
  ...
  <el>
    <node>B</node>
    <rel>
      <el>
        <node>X</node>
        <obj>myobject</obj>
      </el>
    </rel>
  </el>
  ...
</xml>

i want to get a list of the first level nodes (A, B, C..) with their related
nodes (X, Y, Z...) but removing duplicates, so i'd like to get:
        A-XY
        B-X
        ...

but using this -or simmilar principle- basic duplicate removing xsl script:
<!-- to avoid node group repetition -->
<xsl:template match = "/">
  <xsl:apply-templates
select="/xml/el[obj='myobject'][not(node=following::node)]">
    <xsl:sort select="node" />
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="el">
  ...
  <xsl:value-of select="node">-
  <xsl:call-template name="XXX"><xsl:with-param name="node" ><xsl:value-of
select="node" /></xsl:with-param></xsl:call-template>
  ...
</xsl:template>

<xsl:template name="XXX">
  <xsl:for-each
select="/xml/el[node=$node]/rel/el[obj='myobject'][not(node=following-siblin
g::*)]">
    <xsl:value-of select="node">
  </xsl:for-each>
</xsl:template>

i wrongly get this:
        A-XXY
        B-X
        ...

as i don't have tight performance problems i don't need to resort to
muenchian methods, any idea on how to solve this ?

thanks

- - --
"Sobre lo que no se puede hablar hay que pasar de puntillas"
Ludwig Wittgenstein

Juan Valentmn-Pastrana
jvalentin@xxxxxxxxxx
- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAkHwEvwACgkQWSh8rAinIHn1fgCdHlJ0GWlZihM8JGggL1IQQust
4dsAoIbGp317a1SHaTAS0vfKZlkH53g7
=T0VW
- -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAkHwI/4ACgkQWSh8rAinIHnuIACgkfKCplha6/Drzq8fNRfseptc
BxcAn1HcpJ7+HBhyUsACUnIj/XFeX5vp
=78++
-----END PGP SIGNATURE-----


Current Thread
Keywords
xsl