xsl-list
[Top] [All Lists]

help on removing duplicates

2005-01-20 14:34:54
-----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 Valentín-Pastrana
jvalentin(_at_)arrakis(_dot_)es
- -----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-----


--~------------------------------------------------------------------
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>