Consider the DocBook article in test.xml which contains an <informaltable>
that is repeated at the beginning of each section. Consider also that the <informaltable>
is actually much more complicated than this example shows.
This example accomplishes reuse of the complicated <informaltable>
using an external <!ENTITY ... SYSTEM ...>
declaration. The complicated <informaltable>
is in another file called reusedtable.xml.
test.xml
<!DOCTYPE article [<!ENTITY ReusedTable SYSTEM "reusedtable.xml">]>
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<info>
<title>Article Template Title</title>
</info>
<section>
<title>first title</title>
&ReusedTable;
</section>
<section>
<title>Second Title</title>
&ReusedTable;
</section>
</article>
reusedtable.xml
The file that contains the reused table.
<informaltable>
<tgroup cols='2'>
<tbody>
<row>
<entry>YES</entry>
<entry>NO</entry>
</row>
</tbody>
</tgroup>
</informaltable>
Here's what the output looks like
This method works, but it seems a bit awkward and limited. So it leaves me with the following questions:
- Is there a way to accomplish the reuse of my
<informaltable>
without creating a second .xml file? - Is there a way to accomplish the reuse of my
<informaltable>
so that I could parameterize the table?
For example, I'd like to be able to express the presence of an instance of ReusedTable populated with different content in my docbook article like this,
test2.xml
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<info>
<title>Article Template Title</title>
</info>
<section>
<title>first title</title>
<ReusedTable>
<firstcol>true</firstcol>
<seccol>false</seccol>
</ReusedTable> </section>
<section>
<title>Second Title</title>
<ReusedTable>
<firstcol>yes</firstcol>
<seccol>no</seccol>
</ReusedTable>
</section>
</article>
and have the published output look like this where the design of ReusedTable is defined once and the content of the cells in each instance of ReusedTable comes from markup in the article where the table will appear.