[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] how to remove duplicates from more than one file?


Subject: Re: [xsl] how to remove duplicates from more than one file?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 7 Dec 2002 23:09:15 -0800 (PST)

"Marcin Antczak" <marcin.antczak@xxxxxxxx> wrote in message
news:3DF26233.7070904@xxxxxxxxxxx
> My input is:
>
> root.xml
>
> <root/>
>
>
> items_1.xml
>
> <items>
>  <item name='one'>value_1</item>
>  <item name='one'>value_1</item>
>  <item name='two'>value_2</item>
>  <item name='three'>value_3</item>
> </items>
>
>
> items_2.xml (and more.... items_*.xml)
>
> <items>
>  <item name='one'>value_1</item>
>  <item name='one'>value_1</item>
>  <item name='two'>value_2</item>
>  <item name='two'>value_2</item>
>  <item name='one'>value_1</item>
>  <item name='seven'>value_7</item>
> </items>
>
>
> And I need to generate output with items from all input files without
> duplicates:
>
> <itemList>
>  <item name='one'>value_1</item>
>  <item name='two'>value_2</item>
>  <item name='three'>value_3</item>
>  <item name='seven'>value_7</item>
> </itemList>
>
> My first idea was to grab extrernal data with document() function
into
> variable and then use Muenchian method on nodeset within this
variable.
>
> In my stylesheet I did something like this:
>
> <xsl:key name="items" match="item" use="@name"/>
>
> <xsl:variable name="source">
>      <xsl:copy-of select="document('items_1.xml')//item |
> document('items_2.xml')//item"/>
> </xsl:variable>
>
> <xsl:for-each select="$source">
>      <xsl:for-each
> select="//item[generate-id(.)=generate-id(key('items', @name)[1])]">
>          <test_ok/>
>      </xsl:for-each>
> </xsl:for-each>
>
> But on my windows machine (win 2000 + IIS 5.0 + PHP 4.2.3 + sablotron
> 0.96 - server side transformations) i get only segfaults.
>
> On unix machine (freeBSD) there was no errors but any output at all
either.
>
> Could you give me hint how to resolve this problem?
>
>
> Marcin Antczak


Yes, you can use the "makeDistinct.xsl" stylesheet module from FXSL.

For an explanation and a concrete example see:

http://sources.redhat.com/ml/xsl-list/2002-07/msg00832.html

and

http://sources.redhat.com/ml/xsl-list/2001-12/msg00806.html



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread