Generating unique IDs for XML nodes

I needed to assign a guaranteed unique ID to nodes in a tree. A simple way to do this is to use the sequence number of a node when creating the ID:

<xsl:number format="1" count="//Node" level="any" />

This takes the sequence number (provided by xsl:number) of any node matching “Node”; the level=”any” directive means no hierarchy/sibling information is used; all nodes matching “Node” are taken as being sequentially numbered.

Obviously this works only for the initial set of nodes, but it satisfied the requirements here.