Altova Mailing List Archives


Re: [xsl] combine on key and dedupe

From: David Carlisle <davidc@---.--.-->
To: xsl-list@-----.------------.---
Date: 3/23/2010 1:45:00 AM
On 23/03/2010 01:38, Joyce Chapman wrote:
> Any advice on how to do the following would be greatly appreciated. I
> need to combine and dedupe a list of authors, compiling all children
> of grouped<author>  into one<author>  (grouped on<authorizedName>),
> but deduping the<authorizedName>. See example below. I think I need
> to use an XSL 2.0 for-each-group, but am not sure how. Duplicate
> author elements will not be adjacent to each other. Thanks for any
> help!
>
> Two author records for the same<authorizedName>:
>
> <author>
>    <authorizedName>Joe Bob</authorizedName>
>    <nickName>J-Bob</nickName>
>    <title>Title1</title>
> </author>
>
> <author>
>    <authorizedName>Joe Bob</authorizedName>
>    <nickName>Joe</nickName>
>    <title>Title2</title>
> </author>
>
> Turn into a single author record, compiling all children but deduping
> <authorizedName>:
>
> <author>
>    <authorizedName>Joe Bob</authorizedName>
>    <nickName>Joe</nickName>
>    <nickName>J-Bob</nickName>
>    <exampleTitle>Title1</exampleTitle>
>    <exampleTitle>Title2</exampleTitle>
> </author>
>

<xsl:for-each-group select="author" group-by="authorizedName">
<copy>
<xsl:copy-of select="authorizedName,current-group()/(* except 
authorizedName)"/>
</xsl:copy>
</xsl:for-each-group>


or if necessary sorting teh children by name to bring them back together.

David




--~------------------------------------------------------------------
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@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.