[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi Pankaj,
Pankaj Chaturvedi wrote:
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"/>
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>
Re: [xsl] Split with delimiter and remove duplicate with xsl:for-each group
Subject: Re: [xsl] Split with delimiter and remove duplicate with xsl:for-each group From: Deborah Pickett <debbiep-list-xsl@xxxxxxxxxx> Date: Mon, 30 Jun 2008 22:48:34 +1000 |
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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Split with delimiter and remo, Pankaj Chaturvedi | Thread | Re: [xsl] Split with delimiter and , Martin Honnen |
[xsl] Split with delimiter and remo, Pankaj Chaturvedi | Date | Re: [xsl] Split with delimiter and , Martin Honnen |
Month |