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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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.

   
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.