XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Viral GuptaSubject: check for duplicates.
Author: Viral Gupta
Date: 10 Mar 2007 01:33 AM
Hi,

I am having problem with removing duplicate entires.
Need help.

Follwing is the XMl schema.

<Paper monthid="some number">
<Area> </Area>
<Author>
<Name></Name>
</Author>
<Author>
<Name></Name>
</Author>
<Topic></Topic>
<Year></Year>
<Month></Month>
<Abstract-link></Abstract-link>
<Full-Paper-link></Full-Paper-link>
<Abstract></Abstract>
<Conference></Conference>
</Paper>

ideally Author tags will have same names but not necessarily in same order. so we want to only compare year, topic

Also if u know sm way by which even if authors names follow a different sequence and still can be checked ...then that should be gr8!!...


following is the xslt we are using.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:url="http://www.jclark.com/xt/java/java.net.URLEncoder"
exclude-result-prefixes="url">
<xsl:template match="/">

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>abcd</title>
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" media="all" />
</head>

<body>
<h2>Wireless Security</h2>
<xsl:for-each select="Publications/Paper">
<xsl:sort select="Year" data-type="number" order="descending"/>
<xsl:sort select="@monthid" data-type="number" order="descending"/>

<xsl:if test="Area ='Wireless Security'">
<br/>
<xsl:value-of select="Topic"/>

<br/>

<xsl:for-each select="Author">

<xsl:if test="Name!='false'">
<xsl:value-of select="Name"/>
<xsl:if test="not(position()=last())">
<xsl:text>, </xsl:text>
</xsl:if>
<!-- <xsl:if test="position()=last()">
<br/>
</xsl:if>-->
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="string-length(Full-Paper-link)">
<xsl:text> </xsl:text>
<a>
<xsl:attribute name="href"><xsl:value-of select="Full-Paper-link"/> </xsl:attribute >
<span style="color: #0000ff">
<xsl:text>(PAPER)</xsl:text>
</span>
</a>
<xsl:if test="string-length(Abstract-link)">
<xsl:text> </xsl:text>
<a>
<xsl:attribute name="href"><xsl:value-of select="Abstract-link"/> </xsl:attribute >
<span style="color: #0000ff">
<xsl:text>(ABSTRACT)</xsl:text>
</span>
</a>
</xsl:if>
<br/>
</xsl:when>
<xsl:otherwise>
<br/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="Conference"/>

<xsl:if test="string-length(Month)">
<xsl:text>, </xsl:text>
<xsl:value-of select="Month"/>
</xsl:if>
<!--<xsl:if test="Year!='false'">-->
<xsl:if test="string-length(Year)">
<xsl:text> </xsl:text>
<xsl:value-of select="Year"/>
</xsl:if>
<br/>
<xsl:if test="string-length(Abstract)">
<xsl:text> </xsl:text>
<xsl:value-of select="Abstract"/>
<br/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>

</xsl:stylesheet>


Thanks a lot for the help.
Viral

Posttop
James DurningSubject: check for duplicates.
Author: James Durning
Date: 15 Mar 2007 11:42 AM
I think you can use Muenchian grouping to solve your problem. http://www.jenitennison.com/xslt/grouping/muenchian.html

You'd have at top of stylesheet:
<xsl:key name="Authors-by-Name" match="Author" use="Name" />

And Instead of <xsl:for-each select="Author">
you'd have
<xsl:for-each select="Author[count(. | key('Authors-by-Name', Name)[1]) = 1]"> <!-- gets unique authors by name -->

Inside this for-each loop, to get all authors with the same name, you'd put:
<xsl:for-each select="key('Authors-by-Name', Name)">

Not entirely sure what you want as end output, so you might want an <xsl:sort> inside the first for-each or something else.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.