This is easy and straightforward.
This transformation:
<xsl:stylesheet version="1.0"
xmlns

sl="http://www.w3.org/1999/XSL/Transform">
<xsl

utput omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="item | event">
<xsl:variable name="vRowInd">
<xsl:number count="item | event" level="any"/>
</xsl:variable>
<row index="{$vRowInd - 1}">
<xsl:for-each select="@*">
<cell index="{position() - 1}">
<xsl:value-of select="."/>
</cell>
</xsl:for-each>
</row>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
when applied on your source.xml:
<items>
<item id="0" name="item0">
<event description="item0_event0"/>
<event description="item0_event1"/>
</item>
<item id="1" name="item1">
<event description="item1_event0"/>
<event description="item1_event1"/>
</item>
</items>
produces the wanted result:
<row index="0">
<cell index="0">0</cell>
<cell index="1">item0</cell>
</row>
<row index="1">
<cell index="0">item0_event0</cell>
</row>
<row index="2">
<cell index="0">item0_event1</cell>
</row>
<row index="3">
<cell index="0">1</cell>
<cell index="1">item1</cell>
</row>
<row index="4">
<cell index="0">item1_event0</cell>
</row>
<row index="5">
<cell index="0">item1_event1</cell>
</row>
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Ken" <> wrote in message
news: om...
> The fact that you can not reassign a variable in XSL is an endless
> source of frustration, causing you to jump through all sorts of
> non-intuitive hoops.
>
> In this case, however, the lack of reassignment has me totally
> perplexed on how to achieve a solution to the following problem:
>
> (These are illustrative fragments)
>
> XML:
>
> <item id="0" name="item0">
> <event description="item0_event0"/>
> <event description="item0_event1"/>
> </item>
> <item id="1" name="item1">
> <event description="item1_event0"/>
> <event description="item1_event1"/>
> </item>
>
> XSL: (Incorrect, this is what I'm trying to figure out)
>
> <xsl:for-each select="item">
> <xsl:variable name="baseRow" select="position()"/>
> <row>
> <xsl:attribute name="index"><xsl:value-of
> select="$baseRow"/></xsl:attribute>
> <cell index="0">
> <xsl:value-of select="@id"/>
> </cell>
> <cell index="1">
> <xsl:value-of select="@name"/>
> </cell>
> </row>
> <xsl:for-each select="event">
> <row>
> <xsl:attribute name="index"><xsl:value-of select="$baseRow
> + position()"/></xsl:attribute>
> <cell index="0">
> <xsl:value-of select="@description"/>
> </cell>
> </row>
> </xsl:for-each>
> <!-- <xsl:variable name="baseRow" select="$baseRow +
> count(event)"/> --> <!-- Pseudocode -->
> </xsl:for-each>
>
> DESIRED OUTPUT AFTER XFORM:
>
> <row index="0">
> <cell index="0">0</cell>
> <cell index="1">item0</cell>
> </row>
> <row index="1">
> <cell index="0">item0_event0"</cell>
> </row>
> <row index="2">
> <cell index="0">item0_event1"</cell>
> </row>
> <row index="3">
> <cell index="0">1</cell>
> <cell index="1">item1</cell>
> </row>
> <row index="4">
> <cell index="0">item1_event0"</cell>
> </row>
> <row index="5">
> <cell index="0">item1_event1"</cell>
> </row>
>
> Notice how the row index is continuously incremented. This is my
> desired output, however I cannot figure out how to accomplish it.
> Essentially I like to increment the base position() of the first
> for-each by the count() of the second for-each at the end of the first
> loop.
>
> Thanks for any insight you can provide.