[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
HowTo?: Remove dublicates from a node-set according to conte
Subject: HowTo?: Remove dublicates from a node-set according to content with XT-19990725
From: "Jarno Elovirta" <jarnose@xxxxxxxxxx>
Date: Thu, 29 Jul 1999 04:08:36 +0300
|
I'm trying to find a way to remove duplicate nodes
from a node-set according to the content of the nodes, e.g. ignore all
duplicate reference elements whose name attribute is the same. I couldn't figure out a way
to do it using XPath predicates - can it be done directly with predicates
or is there a way around it using XSLT somehow? Any ideas? Below is an example
where an reference list created from references in the text and the
duplicate references should be removed but aren't.
source:
<?xml
version='1.0'?> <document> This sentence contains
references to something <reference name="foo" source="www.foo.com"/>.
This sentence contains references to something else <reference name="bar"
source="www.bar.com"/>. This sentence contains references to something as
the first one <reference name="foo"
source="www.foo.com"/>. </document>
stylesheet:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns="http://www.w3.org/TR/REC-html40"
result-ns="">
<xsl:template match="/">
<html> <body>
<xsl:apply-templates/>
</body> </html> </xsl:template>
<xsl:template match="document">
<xsl:apply-templates/> <p/>
<xsl:text>References:</xsl:text> <p/>
<xsl:apply-templates mode="list"
select="//reference"/> </xsl:template>
<xsl:template match="reference">
<xsl:text>[</xsl:text> <a
href=""> <xsl:value-of
select="@name"/> </a>
<xsl:text>]</xsl:text> </xsl:template>
<xsl:template mode="list"
match="reference">
<xsl:text>[</xsl:text> <a
name="#{@name}"> <xsl:value-of
select="@name"/> </a> <xsl:text>]
</xsl:text> <a href="">
<xsl:value-of select="@source"/>
</a> <br/> </xsl:template>
</xsl:stylesheet>
: Jarno - waiting for the
rain
|
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|