[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Remove duplicate affiliation

Subject: Re: Remove duplicate affiliation
From: "Terry Badger terry_badger@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 24 Dec 2023 22:58:45 -0000
Re:  Remove duplicate affiliation
This will do what you want:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="xs math xd" version="2.0"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
B B B  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
B B B  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

B B B  <!-- make a variable that has the gen-id of only the first occurance of
the xreflabel contents -->
B B B  <xsl:variable name="affiliations">
B B B B B B B  <xsl:for-each-group group-by="@xreflabel"
select="/authorgroup/author/affiliation">
B B B B B B B B B B B  <!-- take only the first one in the group -->
B B B B B B B B B B B  <xsl:copy-of
select="current-group()[1]/generate-id(.)"/>
B B B B B B B  </xsl:for-each-group>
B B B  </xsl:variable>

B B B  <!-- start at root -->
B B B  <xsl:template match="/authorgroup">
B B B B B B B  <aug>
B B B B B B B B B B B  <!--<xsl:apply-templates mode="a1"/>-->
B B B B B B B B B B B B  <xsl:apply-templates mode="a2"/>
B B B B B B B  </aug>
B B B  </xsl:template>

B B B  <!-- match each author -->
B B B  <xsl:template match="author" mode="a1">
B B B B B B B  <au>
B B B B B B B B B B B  <xsl:value-of select="name"/>
B B B B B B B  </au>
B B B  </xsl:template>

B B B  <!-- drop name on the a2 pass -->
B B B  <xsl:template match="author/name" mode="a2"/>

B B B  <!-- process affiliation elelemts -->
B B B  <xsl:template match="author/affiliation" mode="a2">
B B B B B B B  <!-- debug info -->
B B B B B B B  <!--<gen-id>
B B B B B B B B B B B  <xsl:value-of select="generate-id(.)"/>
B B B B B B B  </gen-id>-->
B B B B B B B  <xsl:if test="./generate-id(.) = tokenize($affiliations, '
')">
B B B B B B B B B B B  <aff>
B B B B B B B B B B B B B B B  <xsl:copy-of select="org | sub | sup"/>
B B B B B B B B B B B B B B B  <xsl:value-of select="./text()"/>
B B B B B B B B B B B  </aff>
B B B B B B B  </xsl:if>
B B B  </xsl:template>

B B B  <!-- drop all -->
B B B  <xsl:template match="* | text() | @* | comment()"/>
</xsl:stylesheet>


Terry Badger






On Wednesday, December 20, 2023 at 05:02:15 AM EST, Joga Singh Rawat
jrawat@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:





Hi Friends,
We need to remove duplicate affiliation that can be unique by @xreflabel.
Could you please let me know any clue.

Input
<authorgroup>
<author>
<name>a</name>
<affiliation xreflabel=b1b><org>..</org> First affiliation</affiliation>
<affiliation xreflabel=b2b><sup>..</sup> Second affiliation</affiliation>
</author>
<author>
<name>b</name>
<affiliation xreflabel=b1b><org>..</org> First affiliation</affiliation>
</author>
<author>
<name>c</name>
<affiliation xreflabel=b3b><org>..</org> Third affiliation</affiliation>
</author>
<author>
<name>d</name>
<affiliation xreflabel=b1b><org>..</org> First affiliation</affiliation>
<affiliation xreflabel=b4b><sub>..</sub> Forth affiliation</affiliation>
</author>
B 
Output
<aug>
<au>a</au>
<au>b</au>
<au>c</au>
<au>d</au>
<aff><org>b&</org> First affiliation</aff>
<aff><sup>b&</sup> Second affiliation</aff>
<aff><org>b&</org> Third affiliation</aff>
<aff><sub>b&</sub> Forth affiliation</aff>
B 


B B XSL-List info and archive
EasyUnsubscribe (by email)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.