Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Grouping by index ... Or something >Thread Next - Re: Grouping by index ... Or something Re: Grouping by index ... Or somethingTo: NULL Date: 12/13/2007 1:43:00 PM
<richard.hallgren@g...> wrote in message
news:5962152b-d307-419b-bf8f-134a746974a2@t......
> Hi,
>
> I have a weird xml fromat that looks something like this (this is just
> a snippet of course):
> ...
> <Node1>
> <Id>1</Id>
> </Node1>
> <Node1>
> <Id>2</Id>
> </Node1>
> <Node2>
> <Name>The first one</Name>
> </Node2>
> <Node2>
> <Name>The second one</Name>
> </Node2>
> ...
>
> The thing is that the first node1 has a correlation to the first node2
> (in the document I'm mapping to i want to have {Id=1, Name=The first
> one} and {Id=2, Name=The second one}). Performace is key here. How can
> I solve this the easiest way? Or any way ...
>
The problem with over simplifying the example XML is that artificial
solutions appear to work, for example this will generate the sort of output
you need however I doubt that it works for the real world XML.
<xsl:for-each select="Node2">
<tr>
<td><xsl:value-of select="position()" /></td>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>
What I think you've left us to guess is that there are as many Node1 nodes
as there are Node2 nodes and that there is a one to one relationship between
their ordinal postions.
Here is a something more likely to be what you are after:-
<xsl:template match="/root">
<xsl:variable name="node1s" select="Node1" />
<xsl:variable name="node2s" select="Node2" />
<html>
<body>
<table>
<xsl:for-each select="$node1s">
<xsl:variable name="position" select="position()" />
<tr>
<td><xsl:value-of select="." /></td>
<td><xsl:value-of select="$node2s[$position]" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
--
Anthony Jones - MVP ASP/ASP.NET
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
