O'Reilly logo

XML Companion, The, Third Edition by Neil Bradley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required