Hi Has anyone considered using the position function? This returns a number equal to the position in the current context set, so should be useful for the kind of thing you want to do. e.g. <!-- c01, c02 etc. links --> <ul> <xsl:for-each select="archdesc/dsc/c01"> <xsl:variable name="c01pos" select="position()"/> <li> <a> <xsl:attribute name="href"> <xsl:text>#series</xsl:text> <xsl:value-of select="$c01pos"/> </xsl:attribute> <xsl:apply-templates select="./did/unittitle"/> </a> <ul> <xsl:for-each select="c02"> <xsl:variable name="c02pos" select="position()"/> <li> <a> <xsl:attribute name="href"> <xsl:text>#series</xsl:text> <xsl:value-of select="$c01pos"/> <xsl:text>-</xsl:text> <xsl:value-of select="$c02pos"/> </xsl:attribute> <xsl:apply-templates select="./did/unittitle"/> </a> <!-- you can nest further lists here if needed ....--> </li> </xsl:for-each> </ul> </li> </xsl:for-each> </ul> <!-- end c01, c02 etc links --> I haven't tested this out yet, and of course you'd need corresponding code to insert the ids at the target position, but I see no reason why it wouldn't work. HTH John -- John Harrison Special Collections and Archives University of Liverpool Library Chatham Street, PO Box 123, Liverpool, L693DA e: [log in to unmask] w: sca.lib.liv.ac.uk t: 0151 7943142 f: 0151 7942681