IS there any way to use XSLT to generate unique IDs (sequential is fine) when they don't already exist? I have the following:
<xsl:template match="Foo">
<xsl:variable name="varName">
<xsl:call-template name="getVarName">
<xsl:with-param name="name" select="@name"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$varName"/> = <xsl:value-of select="@value"/>
</xsl:template>
<xsl:template name="getVarName">
<xsl:param name="name" select="''"/>
<xsl:choose>
<xsl:when test="string-length($name) > 0">
<xsl:value-of select="$name"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>someUniqueID</xsl:text> <!-- Stuck here -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
With an input of something like:
<Foo name="item1" value="100"/>
<Foo name="item2" value="200"/>
<Foo value="300"/>
I'd like to be able to assign a unique value so that I end up with:
item1 = 100
item2 = 200
unnamed1 = 300