|
Subject: [xsl] sort | uniq via keys From: Saverio Perugini <sperugin@xxxxxxxxxxxxxxxx> Date: Thu, 14 Feb 2002 12:09:24 -0500 (EST) |
Hello,
I am interested in a sorted and uniqed list of all element names in
an XML file (except for the root), similar to `sort | uniq' in UNIX.
e.g., in the following data,
<db>
<a>...</a>
<z>...</z>
<g>...</g>
<j>
<f>...</f>
<z>...</z>
<a><o>...</o></a>
</j>
<b>...</b>
<b>...</b>
</db>
I'd like the following list
a
b
f
g
j
o
z
I am trying to achieve this with keys (unless someone can direct me to
a simpler method). The following is an initial attempt.
<xsl:key name="features" match="*" use="name()"/>
<xsl:template match="/db">
<xsl:for-each select="following::*[count (. | key('features', name())[1]) = 1]">
<xsl:sort select="name()" />
<xsl:value-of select="name()" /><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()"/>
This is not working out however. It returns an empty file. Does this
appear to be correct?
Thank You and Best Regards,
Saverio Perugini
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] possiblity to access the xsl , 林 子芯 | Thread | [xsl] differences between fop 0.20 , Bryan Rasmussen |
| Re: [xsl] xsl:number, Wendell Piez | Date | RE: [xsl] match on attribute anywhe, Bryan Rasmussen |
| Month |