This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: I Need to insert C-language code into DocBook XML


>From: dbook@centrum.cz
>To: docbook-apps@lists.oasis-open.org
>Subject: DOCBOOK-APPS: I Need to insert C-language code into DocBook XML
>Date: Tue, 12 Mar 2002 22:08:39 +0100
>
>I have problem - how to put into DocBook XML content of file with
>C-language code?  Problem is, that this content must be placed in external
>file (source.c), no directly in DocBook XML.

I don't see why modifying the C code is such a problem.  I would create a 
proper external parsed entity, by using sed to replace all the dangerous 
characters.  Assuming you only have to worry about ampersands and angle 
brackets, that would look like:
    sed "s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g" source.c > source.c.xml


Then, use source.c.xml, instead of source.c.  If you use a makefile to build 
your document, you could codify this into a rule, so that it would 
automatically get rerun, every time source.c was modified.  FSF (The Free 
Software Foundation) has very good documentation for GNU Make, on their web 
site (fsf.org).


If you use windows, you can get UNIX tools (such as sed and make) via the 
free "cygwin" package, available from RedHat (just search for it, on their 
site).


Matt Gruenke


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]