This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Copying of nodes


> How can I combine the subelements of a given node of two xml files?
> 
> The xml files:
> 
> file1.xml
> <root>
>    <data>
>      <a>...</a>
>      <a>...</a>
>      <b>...</b>
>    </data>
> </root>
> 
> file2.xml
> <root>
>    <data>
>      <a>...</a>
>      <b>...</b>
>      <b>...</b>
>    </data>
> </root>
> 
> The resulting file should look like this one:
> 
> <root>
>    <data>
>      <a>...</a>    (1st <a> from file1)
>      <a>...</a>    (2nd <a> from file1)
>      <a>...</a>    (1st <a> from file2)
>      <b>...</b>    (1st <b> from file1)
>      <b>...</b>    (1st <b> from file2)
>      <b>...</b>    (2nd <b> from file2)
>    </data>
> </root>
> 

<xsl:template match="/">
  <root><data>
    <xsl:for-each select="/root/data/* | document('xxx')/root/data/*">
    <xsl:sort select="name()"/>
    <xsl:copy-of select="."/>
    </xsl:for-each>
  </data></root>
</xsl:template>

Mike Kay
Software AG 

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]