xsl-list
[Top] [All Lists]

AW: [xsl] Merging common XML tree

2010-07-08 04:40:04
Hi, 

You could try this:

<xsl:template match="dir">
        <copy>
                <copy-of select="@*">
        </copy>
        <xsl:if test="following::dir[(_at_)name = current()/@name]">
                <xsl:apply-templates select="following::dir[(_at_)name = 
current()/@name]/*"/>
        </xsl:if>
</xsl:template> 

Haven't tested this but the solution should be something like this.

cheers


Patrick Szabo
 XSLT-Entwickler 

Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 

Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at

LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
http://www.lexisnexis.at/
 
-----Ursprüngliche Nachricht-----

Von: Mathieu Malaterre [mailto:mathieu(_dot_)malaterre(_at_)gmail(_dot_)com] 
Gesendet: Donnerstag, 08. Juli 2010 11:30
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: [xsl] Merging common XML tree

Hi there,

  I am trying to find a solution for the following problem. Let's
assume that my input XML tree looks like:

<dirs>
  <dir name="A">
    <dir name="B">
      <file name="C">
    </dir>
  </dir>
  <dir name="A">
    <dir name="B">
      <file name="D">
    </dir>
  </dir>
</dirs>

and my target output tree should looks like:

<dirs>
  <dir name="A">
    <dir name="B">
      <file name="C">
      <file name="D">
    </dir>
  </dir>
</dirs>

Basically I am trying to represent a dir/file structure in XML, where
I am not allowed to repeat common subdirectory. What XSL function
could I use to do that (XSTL 1.0 if possible).

Thanks !
-- 
Mathieu

--~------------------------------------------------------------------
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>