[Home] [By Thread] [By Date] [Recent Entries]
Pankaj Chaturvedi wrote:
<xsl:template name="affiliation"> <xsl:for-each-group select=".//Affiliation" group-by="./Author/Affiliation"> <xsl:value-of select="current-grouping-key()"/> <xsl:for-each select="tokenize(., '\[\d+\]')[normalize-space(.)]"> <affil> <xsl:value-of select="normalize-space(current-grouping-key())"/> </affil> </xsl:for-each> </xsl:for-each-group> </xsl:template> I would first tokenize, then use xsl:for-each-group to remove duplicates: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:variable name="affiliations" as="element()*"> <xsl:for-each select="for $a in Article/AuthorList/Author/Affiliation return tokenize($a, '\[\d+\]')[normalize-space(.)]"> <affil> <xsl:value-of select="normalize-space(.)"/> </affil> </xsl:for-each> </xsl:variable> <affiliationList> <xsl:for-each-group select="$affiliations" group-by="."> <xsl:copy-of select="current-group()[1]"/> </xsl:for-each-group> </affiliationList> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://JavaScript.FAQTs.com/
|

Cart



