I have three files of xml
<step>
<Products>
<Product UserTypeID="Country">
<Name>Cyprus</Name>
<Product UserTypeID="Resort">
<Name>Argaka</Name>
<Product UserTypeID="Property">
<Name>Villa Tester</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Coral Bay</Name>
<Product UserTypeID="Property">
<Name>1</Name>
</Product>
<Product UserTypeID="Property">
<Name>2</Name>
</Product>
</Product>
</Product>
<Product UserTypeID="Country">
<Name>Greece</Name>
<Product UserTypeID="Region">
<Name>Corfu</Name>
<Product UserTypeID="Resort">
<Name>Aghios Stefanos</Name>
<Product UserTypeID="Property">
<Name>Villa Joanna</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Eleonas</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Kassiopi</Name>
<Product UserTypeID="Property">
<Name>Villa 2</Name>
</Product>
</Product>
</Product>
</Product>
</Products>
<step>
<Products>
<Product UserTypeID="Country">
<Name>Cyprus</Name>
<Product UserTypeID="Resort">
<Name>Argaka</Name>
<Product UserTypeID="Property">
<Name>Villa Jaime</Name>
</Product>
</Product>
</Product>
<Product UserTypeID="Country">
<Name>Greece</Name>
<Product UserTypeID="Region">
<Name>Corfu</Name>
<Product UserTypeID="Resort">
<Name>Acharavi</Name>
<Product UserTypeID="Property">
<Name>Villa 1</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa 2</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Gouvia</Name>
<Product UserTypeID="Property">
<Name>Villa De Bono</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Kassiopi</Name>
<Product UserTypeID="Property">
<Name>Villa 1</Name>
</Product>
</Product>
</Product>
</Product>
</Products>
<step>
<Products>
<Product UserTypeID="Country">
<Name>Cyprus</Name>
<Product UserTypeID="Resort">
<Name>Aghia Marina</Name>
<Product UserTypeID="Property">
<Name>Villa Aghia Marina</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Coral Bay</Name>
<Product UserTypeID="Property">
<Name>Ascos Coral Villas</Name>
</Product>
<Product UserTypeID="Property">
<Name>Coral Villa</Name>
</Product>
<Product UserTypeID="Property">
<Name>Lella Villas</Name>
</Product>
</Product>
</Product>
<Product UserTypeID="Country">
<Name>Greece</Name>
<Product UserTypeID="Region">
<Name>Corfu</Name>
<Product UserTypeID="Resort">
<Name>Acharavi</Name>
<Product UserTypeID="Property">
<Name>Villa Angelos</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Eleonas</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Aghios Stefanos</Name>
<Product UserTypeID="Property">
<Name>Villa Joanna</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Eleonas</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Kassiopi</Name>
<Product UserTypeID="Property">
<Name>Villa Imerolia</Name>
</Product>
<Product UserTypeID="Property">
<Name>Test Property</Name>
</Product>
</Product>
</Product>
</Product>
</Products>
Each file has the same products (by ./name) but with differing sub products (by ./name) and I need to concatenate them into one tree with one product per product/name, containing all sub products on the same rules so that I can output one structure.
I have an xslt method found, that will create a node set as below
<xsl:variable name="step-output">
<xsl:for-each select="/index/file">
<xsl:copy-of select="document(.)" />
</xsl:for-each>
</xsl:variable>
<xsl:variable name="step-products" select="exsl:node-set($step-output)//Products" />
But this, when I create other templates will create three products by product/name, i.e. cyprus will turn up three times.
Does anyone know how to do what I'm after?? My result needs to be as follows
<step>
<Products>
<Product UserTypeID="Country">
<Name>Cyprus</Name>
<Product UserTypeID="Resort">
<Name>Aghia Marina</Name>
<Product UserTypeID="Property">
<Name>Villa Aghia Marina</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Argaka</Name>
<Product UserTypeID="Property">
<Name>Villa Jaime</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Tester</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Coral Bay</Name>
<Product UserTypeID="Property">
<Name>Ascos Coral Villas</Name>
</Product>
<Product UserTypeID="Property">
<Name>Coral Villa</Name>
</Product>
<Product UserTypeID="Property">
<Name>Lella Villas</Name>
</Product>
<Product UserTypeID="Property">
<Name>1</Name>
</Product>
<Product UserTypeID="Property">
<Name>2</Name>
</Product>
</Product>
</Product>
<Product UserTypeID="Country">
<Name>Greece</Name>
<Product UserTypeID="Region">
<Name>Corfu</Name>
<Product UserTypeID="Resort">
<Name>Acharavi</Name>
<Product UserTypeID="Property">
<Name>Villa Angelos</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Eleonas</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa 1</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa 2</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Aghios Stefanos</Name>
<Product UserTypeID="Property">
<Name>Villa Joanna</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa Eleonas</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Gouvia</Name>
<Product UserTypeID="Property">
<Name>Villa De Bono</Name>
</Product>
</Product>
<Product UserTypeID="Resort">
<Name>Kassiopi</Name>
<Product UserTypeID="Property">
<Name>Villa Imerolia</Name>
</Product>
<Product UserTypeID="Property">
<Name>Test Property</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa 1</Name>
</Product>
<Product UserTypeID="Property">
<Name>Villa 2</Name>
</Product>
</Product>
</Product>
</Product>
</Products>