I have the following code:
<Parent>
<Map sourcename="ItemAName" destinationname="itemaname">
<Assignment source="Test.OrderA.ItemA" destination="Test.OrderB.ItemA" sourcename="ItemAName" destinationname="ITEMANAME" description="descript3" mandatory="False"/>
<Assignment source="Test.OrderB.ItemA" destination="Test.OrderC.ItemA" sourcename="ITEMANAME" destinationname="itemaname" description="descript3" mandatory="False"/>
</Map>
<Map sourcename="ItemAQuantity" destinationname="itemaquantity">
<Assignment source="Test.OrderA.ItemA" destination="Test.OrderB.ItemA" sourcename="ItemAQuantity" destinationname="ITEMAQUANTITY" description="descript4" mandatory="False"/>
<Assignment source="Test.OrderB.ItemA" destination="Test.OrderC.ItemA" sourcename="ITEMAQUANTITY" destinationname="itemaquantity" description="descript4" mandatory="False"/>
<Assignment source="Test.OrderC.ItemA" destination="Test.OrderD.ItemA" sourcename="itemaquantity" destinationname="ItEmQuAnTiTy" description="descript4" mandatory="False"/>
</Map>
</Parent>
I want to display a table that contains 6 columns (number of assignments in the Map which contains more children * 2), in this case. Sometimes it will require more or less, according to the data in the xml file. If I add another map with four assignments, the table should have 8 columns.
I'm using this:
<xsl:template match="Map">
<xsl:if test="position() = 1">
<tr class="bold">
<xsl:for-each select="Assignment">
<td><xsl:value-of select="@source"/></td>
<td><xsl:value-of select="@destination"/></td>
</xsl:for-each>
</tr>
</xsl:if>
<tr>
<xsl:apply-templates select="Assignment"/>
</tr>
</xsl:template>
<xsl:template match="Assignment">
<td><xsl:value-of select="@sourcename" /></td>
<td><xsl:value-of select="@destinationname" /></td>
</xsl:template>
I know I should not use the if to test if its the first position. I need a way to count the number of assignments in the child who has more assignments.
Is there a way to do that?