Re: [xsl] From filepaths to XML hierarchy

Subject: Re: [xsl] From filepaths to XML hierarchy
From: Jesper Tverskov <jesper@xxxxxxxxxxx>
Date: Tue, 27 Dec 2011 15:01:22 +0100
That's it! Thanks.

This is the kind of solution I would love to be able to do on the fly
without having to think about it. I'm not there yet.



On Tue, Dec 27, 2011 at 2:50 PM, Martin Honnen <Martin.Honnen@xxxxxx> wrote:
> Jesper Tverskov wrote:
>
>> Let us reduce the problem to the following input file:
>> <x>
>> B  B <a><b><c/></b></a>
>> B  B <a><b><d/></b></a>
>> B  B <a><b><e/></b></a>
>> B  B <h><i/></h>
>> B  B <h><j/></h>
>> </x>
>>
>> How can I transform it into the following output:
>> <x>
>> B  B <a><b><c/><d/><e/></b></a>
>> B  B <h><i/><j/></h>
>> </x>
>
>
> Try
>
> <xsl:stylesheet
> B xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> B version="2.0">
>
> B <xsl:template match="*">
> B  B <xsl:param name="group" select="*"/>
> B  B <xsl:copy>
> B  B  B <xsl:for-each-group select="$group" group-by="node-name(.)">
> B  B  B  B <xsl:apply-templates select=".">
> B  B  B  B  B <xsl:with-param name="group" select="current-group()/*"/>
> B  B  B  B </xsl:apply-templates>
> B  B  B </xsl:for-each-group>
> B  B </xsl:copy>
> B </xsl:template>
>
> </xsl:stylesheet>
>
> although I am not sure I have understood completely what you want to
> achieve.
>
>
> --
>
> B  B  B  B Martin Honnen --- MVP Data Platform Development
> B  B  B  B http://msmvps.com/blogs/martin_honnen/

Current Thread