Using generate-id to Create Unique Identifiers

It’s important to consider another topic when you’re substantially reorganizing documents: how to create identifiers in the result document that you can use to identify elements and so refer to them if needed. For example, imagine that you want to use an XSLT stylesheet to add a table of contents to a document and to make the entries in the table of contents hyperlinks so the user has only to click them to jump to the right section. In that case, you need some way of identifying elements in the result document, and the generate-id function is useful here.

In the following example, I add a hyperlinked table of contents to plan-ets.html. To generate that table of contents, I use <xsl:for-each>to loop ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.