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.

Join the discussion...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.