OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [docbook] <informalexample> to contain one or multiple <programlisting> element(s) for a multi-line source code block?


Please, don't post in HTML format; it's hard to read and answer to.

What do you want to do? Producing HTML output with a XSLT processor like
Saxon or Xalan?

The correct usage of the <programlisting> element is described on:

http://www.docbook.org/tdg/en/html/programlisting.html

"This element is displayed "verbatim"; whitespace and linebreaks within this
element are significant."

As you can see, there is no need to wrap every line of the listing with
<programlisting>. 

If you use <[CDATA[ ... e.g. Java-Listing here ... ]]>, white space and line
breaks are significant, too. The only difference is, that docbook markup is
not recognised. 

Regards,
Gisbert Amm
http://web.de/

-----Original Message-----
From: Taro Ikai [mailto:tikai@ABINITIO.COM]
Sent: Monday, July 07, 2003 4:49 PM
To: docbook@lists.oasis-open.org
Subject: [docbook] <informalexample> to contain one or multiple
<programlisting> element(s) for a multi-line source code block?



http://www.docbook.org/tdg/en/html/informalexample.html 

cites an example of <informalexample><programlisting> block that contains 
several lines of source code block in a single <programlisting> element: 

<informalexample>
<programlisting>
sub print_content_model {
   my($self) = shift;
   local($_) = shift;
   local(*FILE) = shift;

   my(@cm) = $self->format_content_model2($_);
   foreach $_ (@cm) {
       print FILE $self->make_links($_, 1, 1), "\n";
   }
}
</programlisting>
</informalexample>

My limited understanding of XML is that it does not pay attention to 
the white spaces or new lines within CDATA sections. The CYGWIN 
distribution of Tidy, for example, does not not preserve 
the new lines within CDATA. 

Am I better off to use something like the following? 

<informalexample> 
  <programlisting>sub print_content_model {</programlisting> 
  <programlisting>&nbsp;&nbsp;my($self) = shift;</programlisting> 
  <programlisting>&nbsp;&nbsp;local($_) = shift;</programlisting> 
  <programlisting>&nbsp;&nbsp;local(*FILE) = shift;</programlisting> 
  <programlisting>&nbsp;&nbsp; my(@cm) =
$self->format_content_model2($_);</programlisting> 
  <programlisting/> 
  <programlisting>&nbsp;&nbsp;foreach $_ (@cm) {</programlisting> 
  <programlisting>&nbsp;&nbsp;    print FILE $self->make_links($_, 1, 1),
"\n";</programlisting> 
  <programlisting>&nbsp;&nbsp;}</programlisting> 
  <programlisting>}</programlisting> 
</informalexample> 

Taro Ikai


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]