I am using XSLT to convert a very large XML document into (X)HTML. For some of the tags I am converting them to a
The natural/idiomatic/failsafe solution would be:
It's not incrementing, but it's guaranteed to be unique. And it's going to produce HTML-valid ID strings (name tokens).
EDIT: If it must be incrementing, do something like the following:
You can use format-number()
to adapt the output of position()
to your needs.
position()
will return the node position relative to the "batch" that is currently being processed. With an explicit call to
you make sure that they are numbered the way you want.