tags:

views:

15

answers:

1

In my DocBook document I have several sections, which follow this pattern:

  • the section name
  • the short description
  • the long description

I'd like to create an index of these sections. But I need it to be a table, which is formatted the following way:

| link_with_section_name | short_description |
| <link id="section1_id">the section name 1</link> | the short description 1 |
| <link id="section2_id">the section name 2</link> | the short description 2 |

I don't like the idea of duplicating the short description. I would like to create some kind of reference in the second column, so that the short description would be taken directly from the referenced section. I could probably create an xterm reference, with the endterm attribute, but I don't want to create a link at the second column. I just want to copy the content from the paragraph which contains the short description.

Is there any way to do it in DocBook?

A: 

This is where XSLT can be made to work.

You need to create the table's template with XPATH rules for filling the table from your existing document.

You need to include that table at the appropriate place.

You then need to use an Ant (or Make or Maven or SCONS) to (1) run your transform to generate your table, then (2) run your ordinary DocBook transforms.

An alternative that I've used is to write the transformation in Python using ElementTree XML parser.

The essential part of this recipe is to build the table just one step in building HTML or LaTeX from your DocBook.

S.Lott