Re: example code



Murray-

Sorry for taking so long in replying.  This problem is quite interesting
and I don't have a good solution for it.

You need to enclose the coding example file in the <![CDATA[ code ]]>
tags where code is your source code.  This ignores anything inside the
brackets and just displays is as plain text.  So, you cannot place an
entity inside the square brackets as it will be ignored and the entity
resolution will not happen.

The solution the GDP has used in the Handbook, where we include our
templates inside, is to make a new file called templates.xml.cdata which
is a copy of the file templates.xml but enclosed in the CDATA tag.  This
isn't what you were wanting though.

The problem here is getting the CDATA tag around the code inside the
document.  I'm thinking you cannot do this using regular XML methods,
but are going to need to preprocess the source code you want to include
and add <![CDATA[ at the beginning of the file and ]]> at the end of the
file and copy it to where your DocBook file is located.  Then you can
include the source code inside the document using entities as I've
described earlier.

Or you can use the dirty and improper way Alexander described.

Eric Baudais

On Thu, 2002-06-20 at 12:47, Murray Cumming wrote:
> On Wed, 2002-06-19 at 21:47, Eric Baudais wrote:
> > Murray-
> > 
> > You can use an entity which is a file with the source code you want to
> > display.  Each entity will point to a file which will be included
> > automatically in the DocBook XML.  So, if you want example.cc to be
> > included in the document just put:
> > 
> > <!ENTITY example SYSTEM "example.cc">
> > 
> > between the square brackets at the end of the DTD.  Then you have
> > include the entity you made in the DocBook:
> > 
> > &example;
> > 
> > This will include the file example.cc wherever you want in the DocBook
> > file.
> 
> Thanks, that seems to need example.cc to be escaped, and source code
> isn't escaped. For instance, I get errors about "<" characters in the
> source code.
> 
> -- 
> Murray Cumming
> murrayc usa net
> www.murrayc.com
> 
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]