[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Split with delimiter and remove duplicate with xs
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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|