Hi,
thanks so much, it works.
Sven
Pieter Reint Siegers Kort wrote:
Hi Sven,
You're dealing with a typical grouping problem, in XSLT this is done using
xsl:key, generate-id(), and key(); try this stylesheet on your XML (I've
used HTML as the output):
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="ids" match="*[(_at_)id]" use="@id" />
<xsl:template match="/tc">
<table>
<tr><th>Id</th><th>Name</th></tr>
<xsl:apply-templates select="pc" />
</table>
</xsl:template>
<xsl:template match="pc">
<xsl:apply-templates
select="*[(_at_)id and generate-id(.)=generate-id(key('ids', @id))]" />
</xsl:template>
<xsl:template match="*[(_at_)id]">
<tr>
<!-- first column is the value of the id attribute -->
<td><xsl:value-of select="@id" /></td>
<!-- second column is the name -->
<td><xsl:value-of select="@name" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
It outputs:
<?xml version='1.0' ?>
<table>
<tr><th>Id</th><th>Name</th></tr>
<tr><td>1</td><td>10000</td></tr>
<tr><td>2</td><td>10001</td></tr>
<tr><td>3</td><td>1</td></tr>
</table>
I've tested it with StylusStudio 6 Release 2.
Cheers,
<prs/>
-----Original Message-----
From: Sven Waibel [mailto:sven(_dot_)waibel(_at_)imbus(_dot_)de]
Sent: Martes, 15 de Marzo de 2005 07:01 a.m.
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Doublet
Hi everybody,
i got following result:
10000
10001
1
10000
I want to have:
10000
10001
1
I don't want to get doublets.
Does anybody know something about it?
Thanks in advance and best regards
Sven
my xsl:
----------------------------------
<xsl:template match="pc">
<xsl:for-each select="error-id">
<fo:block>
<xsl:value-of select="@name"/>
</fo:block>
</xsl:for-each>
</xsl:template>
---------------------------------
my xml:
---------------------------------
<tc>
<pc>
<error-id id="1" name="10000" />
<error-id id="2" name="10001"/>
</pc>
<pc>
<error-id id="3" name="1" />
<error-id id="1" name="10000"/>
</pc>
</tc>
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--