Hi Pankaj,
Pankaj Chaturvedi wrote:
I am trying to use the combination of <xsl:for-each-group> to avoid
duplicate and split data of <Affiliation> , using [number] as the delimiter.
This looks like a problem for distinct-values() rather than for-each-group.
Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output indent="yes"/>
<xsl:template match="/Article">
<xsl:variable name="affiliations" as="xs:string+">
<xsl:for-each select="//Affiliation">
<xsl:analyze-string select="string(.)"
regex="\[\d+\]([^\[]*)">
<xsl:matching-substring>
<xsl:sequence
select="normalize-space(regex-group(1))"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:if test="normalize-space(.)">
<xsl:sequence select="normalize-space(.)"/>
</xsl:if>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</xsl:variable>
<affiliationlist>
<xsl:for-each select="distinct-values($affiliations)">
<affil><xsl:value-of select="."/></affil>
</xsl:for-each>
</affiliationlist>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<affiliationlist>
<affil>1Department of Cell and Cancer Biology, University of
Cincinnati, Cincinnati, OH, USA</affil>
<affil>4Division of Biomedical Informatics, Cincinnati Children's
Hospital Medical Center, Cincinnati, OH, USA</affil>
<affil>3Department of Pediatrics, University of Cincinnati,
Cincinnati, OH, USA</affil>
</affiliationlist>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--