atom feed10 messages in org.oasis-open.lists.docbookRe: DOCBOOK: Inserting external code ...
FromSent OnAttachments
Joachim ZieglerOct 23, 2002 8:42 am 
Bob StaytonOct 23, 2002 9:26 am 
Joachim ZieglerOct 24, 2002 6:06 am 
Jens StavnstrupOct 24, 2002 7:15 am 
Bob StaytonOct 24, 2002 9:33 am 
David N. WeltonJun 10, 2003 9:23 am 
Bob StaytonJun 11, 2003 9:11 am 
David N. WeltonJun 12, 2003 2:49 am 
Oliver FischerJun 14, 2003 8:08 am 
Vitaly OstaninJun 16, 2003 7:51 am 
Subject:Re: DOCBOOK: Inserting external code into docbook
From:Bob Stayton (bo@caldera.com)
Date:Oct 23, 2002 9:26:31 am
List:org.oasis-open.lists.docbook

On Wed, Oct 23, 2002 at 05:42:46PM +0200, Joachim Ziegler wrote:

According to question 26 in the DocBook Markup FAQ, I tried the following:

------------------------------ (Bob Stayton says)

You can use following construct to include external code.

You only need the inlinemediaobject wrapper if you are using 4.1.2.

<programlisting><inlinemediaobject> <textobject> <textdata fileref="yourfile.txt"/> </textobject> </inlinemediaobject></programlisting>

------------------------------

I am using 4.1.2 but I get the following errors:

Pythonbuch.xml:51: validity error: No declaration for attribute fileref on element textdata <textdata fileref="yourfile.txt"/> ^ Pythonbuch.xml:51: validity error: No declaration for element textdata <textdata fileref="yourfile.txt"/> ^ Pythonbuch.xml:52: validity error: Element textobject content doesn't follow the Dtd Expecting (objectinfo? , (phrase | calloutlist | glosslist | itemizedlist | orderedlist | segmentedlist | simplelist | variablelist | caution | important | note | tip | warning | literallayout | programlisting | programlistingco | screen | screenco | screenshot | formalpara | para | simpara | blockquote+)), got (textdata )

What's the preferred way to include external program listings in a DocBook document? BTW: I don't understand the semantics of the above nesting of elements.

The FAQ misquotes the mail thread. I didn't supply the incorrect usage for 4.1.2, I just provided the way to do it for 4.2 using textobject. In the 4.1.2 DTD, inlinemediaobject does not support textobject by itself, and textdata is not even an element in 4.1.2.

Looking back in the archives, it seems that this is how you do it with 4.1.2:

<programlisting> <inlinemediaobject> <imageobject> <imagedata fileref="myfunc.c" format="linespecific"/> </imageobject> </inlinemediaobject> <programlisting>

This is processed by an XSLT extension function to insert text from a file and escape the XML markup characters. Such extension functions are available for Saxon and Xalan, but not currently for xsltproc. To enable this extension, you have to set two parameters, either in your customization layer or on the command line. The parameters are use.extensions=1 and textinsert.extension=1. Both must be set for it to work.