Is there a dynamic way to get the 2nd occurrence of an attribute ?
For this XML example, I'd like to get the first 12 values of the SummaryCell/@Name value into a variable Month01, Month02, and so on;
<SummaryHeader>
<SummaryColumnGroup Name="2014">
<SummaryCell Name="Feb14" Type="Text" Value="Feb"/>
<SummaryCell Name="Jan14" Type="Text" Value="Jan"/>
</SummaryColumnGroup>
<SummaryColumnGroup Name="2013">
<SummaryCell Name="Dec13" Type="Text" Value="Dec"/>
<SummaryCell Name="Nov13" Type="Text" Value="Nov"/>
<SummaryCell Name="Oct13" Type="Text" Value="Oct"/>
<SummaryCell Name="Sep13" Type="Text" Value="Sep"/>
<SummaryCell Name="Aug13" Type="Text" Value="Aug"/>
<SummaryCell Name="Jul13" Type="Text" Value="Jul"/>
<SummaryCell Name="Jun13" Type="Text" Value="Jun"/>
<SummaryCell Name="May13" Type="Text" Value="May"/>
<SummaryCell Name="Apr13" Type="Text" Value="Apr"/>
<SummaryCell Name="Mar13" Type="Text" Value="Mar"/>
<SummaryCell Name="Feb13" Type="Text" Value="Feb"/>
<SummaryCell Name="Jan13" Type="Text" Value="Jan"/>
</SummaryColumnGroup>
The following is the XSL I have used;
<xsl:variable name="Month01" select="//SummaryHeader/SummaryColumnGroup/SummaryCell[1]/@Name"/>
<xsl:variable name="Month02" select="//SummaryHeader/SummaryColumnGroup/SummaryCell[2]/@Name"/>
<xsl:variable name="Month03" select="//SummaryHeader/SummaryColumnGroup/SummaryCell[3]/@Name"/>
Desired Output:
<Month01>Feb14</Month01>
<Month02>Jan14</Month02>
<Month03>Dec13</Month03>
Actual Output:
<Month01>Feb14</Month01>
<Month02>Jan14</Month02>
<Month03>Oct13</Month03>
What happens is, SummaryCell[3] actually picks up the the 3rd SummaryCell of the following SummaryColumnGroup, and not iterates through to the 3rd occurrences of SummaryCell.
Note: The number of SummaryCell within a SummaryColumnGroup is dynamic, not specifically the same as the above example.