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: Wanna remove duplicate entries.
Author: Viral Gupta
Date: 08 Mar 2007 01:37 PM
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>

There are three xml files and I want to take out distinct papers
(i.e. both files can have same paper. In that case i only need
distinct papers to be used to create an html using xsl).
Papers with same authors, year, full-paper-link same are considered to be same.


Following is the xsl I am using right now. This is not checking for distinct entries.

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

Postnext
Ivan PedruzziSubject: Wanna remove duplicate entries.
Author: Ivan Pedruzzi
Date: 09 Mar 2007 12:06 AM

Viral

Assuming that the only why to determine if a paper has duplicates is to compare the content of all its sub elements, try the following

<xsl:for-each select="Publications/Paper[not(. = following-sibling::Paper)]">

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
Viral GuptaSubject: Wanna remove duplicate entries.
Author: Viral Gupta
Date: 09 Mar 2007 06:13 PM
Hi..thnaks for the resp...
this works when all entries are same...
Now what if xml data is...
<Paper>
<Author>
<Name>A</Name>
</Author>
<Author>
<Name>Y</Name>
</Author>
<Author>
<Name>YA</Name>
</Author>
<Topic></Topic>
<Year></Year>
<Month></Month>
<Abstract-link></Abstract-link>
<Full-Paper-link></Full-Paper-link>
<Abstract></Abstract>
<Conference></Conference>
</Paper>


and other is
<Paper>
<Author>
<Name>Y</Name>
</Author>
<Author>
<Name>YA</Name>
</Author>
<Author>
<Name>A</Name>
</Author>
<Topic></Topic>
<Year></Year>
<Month></Month>
<Abstract-link></Abstract-link>
<Full-Paper-link></Full-Paper-link>
<Abstract></Abstract>
<Conference></Conference>
</Paper>


this is considered as 2 entries....
ideally Author tags will have same names but not necessarily in same order. so we want to only compare year, topic, full paper link...and if all three are same then its a duplicate entry.

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!!...

Thanks a lot for the help.
Viral

 
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-2016 All Rights Reserved.