Automatic numbering

In many XML documents, list items are not physically numbered in the text. This approach makes it easy to insert, move or delete items without having to edit the prefix of all the other items. In such circumstances, the stylesheet must add the required numbering. In the simplest case, a list of item numbers is added by inserting the Number element at the appropriate position relative to the content:

<template match="item">
  <html:P><number/>) <apply-templates/></html:P>
</template>


    <P>1) item one</P>
    <P>2) item two</P>
    <P>3) item three</P>

Simple numbering

In the simple case shown above, each Item element is assigned a number based on its sequential position among other elements of the same type. Elements of different types ...

Get XML Companion, The, Third Edition 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.