Question

Is it possible for me to write an orderlist in docbook like this so that the text in a paragraph refers to previous listitem labels? For instance I would like the 3rd paragraph in the following to automagically resolve to "Repeat steps 1 to 2".

<orderedlist numeration="arabic">
  <listitem>
    <para>Do foo</para>
  </listitem>
  <listitem>
    <para>Do bar</para>
  </listitem>
  <listitem>
    <para>Repeat steps # to #</para>
  </listitem>
  <listitem>
    <para>Do baz</para>
  </listitem>
</orderedlist>
Was it helpful?

Solution

Yes, it's possible. Use xml:id and <xref linkend="..."/>:

<orderedlist numeration="arabic">
  <listitem xml:id="foo">
    <para>Do foo</para>
  </listitem>
  <listitem xml:id="bar">
    <para>Do bar</para>
  </listitem>
  <listitem>
    <para>Repeat steps <xref linkend="foo"/> to <xref linkend="bar"/>.</para>
  </listitem>
  <listitem>
    <para>Do baz</para>
  </listitem>
</orderedlist>

When processing a DocBook source file containing the above markup with DocBook-XSL, you will get "Repeat steps 1 to 2" in the resulting HTML (or PDF).

If you are not using DocBook 5, change xml:id to id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top