xsl-list
[Top] [All Lists]

Re: [xsl] From filepaths to XML hierarchy

2011-12-27 08:01:33
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(_dot_)Honnen(_at_)gmx(_dot_)de> wrote:
Jesper Tverskov wrote:

Let us reduce the problem to the following input file:
<x>
   <a><b><c/></b></a>
   <a><b><d/></b></a>
   <a><b><e/></b></a>
   <h><i/></h>
   <h><j/></h>
</x>

How can I transform it into the following output:
<x>
   <a><b><c/><d/><e/></b></a>
   <h><i/><j/></h>
</x>


Try

<xsl:stylesheet
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 version="2.0">

 <xsl:template match="*">
   <xsl:param name="group" select="*"/>
   <xsl:copy>
     <xsl:for-each-group select="$group" group-by="node-name(.)">
       <xsl:apply-templates select=".">
         <xsl:with-param name="group" select="current-group()/*"/>
       </xsl:apply-templates>
     </xsl:for-each-group>
   </xsl:copy>
 </xsl:template>

</xsl:stylesheet>

although I am not sure I have understood completely what you want to
achieve.


--

       Martin Honnen --- MVP Data Platform Development
       http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>