/[ddp]/manuals/trunk/sgml-howto/howto.db
ViewVC logotype

Contents of /manuals/trunk/sgml-howto/howto.db

Parent Directory Parent Directory | Revision Log Revision Log


Revision 860 - (show annotations) (download)
Wed Oct 13 15:35:03 1999 UTC (13 years, 8 months ago) by bortz
File size: 42246 byte(s)
* Fixes for the Debian documentations in potato. Now, all the links work.
* A few typos fixed.
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!DOCTYPE article PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1//EN"
4 "dtd/docbook-xml/docbookx.dtd"[
5
6 <!-- TODO: a <man> element with a link to -->
7 <!-- http://www.sources.org/cgi-bin/dwww?type=man&location=/usr/man/man1/sgml2latex.1.gz for the HTML output -->
8
9 <!-- TODO: externalize the following declarations in other -->
10 <!-- files. Warning: this will mean a validating XML parser to treat -->
11 <!-- the conditionals. First attemps with XML:/Checker are not -->
12 <!-- convincing. -->
13
14 <!-- Programs -->
15 <!ENTITY sgmltools2 '<link linkend="sgmltools2">SGMLtools, version 2</link>'>
16 <!ENTITY sgmltools1 '<link linkend="sgmltools1">sgml-tools, version 1</link>'>
17 <!ENTITY jade '<link linkend="jade">jade</link>'>
18 <!ENTITY jadetex '<link linkend="jadetex">jadetex</link>'>
19 <!ENTITY psgml '<application>Emacs</application>&apos; SGML mode, <link linkend="psgml">psgml</link>'>
20 <!ENTITY modular_ss '<link linkend="modularss">Modular DocBook Stylesheets</link>'>
21
22 <!-- Files -->
23 <!ENTITY print_ss
24 '/usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/print/docbook.dsl'>
25 <!ENTITY html_ss
26 '/usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/html/docbook.dsl'>
27 <!ENTITY xml_decl '<filename>/usr/lib/sgml/declaration/xml.decl</filename>'>
28
29 <!-- New elements -->
30
31 <!-- The contents of the debianpackage element is the official name -->
32 <!-- The name attribute holds the Debian name, if it's different -->
33 <!ELEMENT debianpackage (#PCDATA)>
34 <!ATTLIST debianpackage name CDATA #IMPLIED>
35 <!ATTLIST debianpackage refserver CDATA #IMPLIED>
36 <!ENTITY % local.title.char.mix
37 "|debianpackage">
38
39 <!ELEMENT debiandoc (#PCDATA)>
40 <!ATTLIST debiandoc file CDATA #IMPLIED>
41 <!ATTLIST debiandoc text CDATA #IMPLIED>
42 <!ENTITY % local.para.char.mix
43 "|debiandoc|debianpackage">
44
45 <!ELEMENT manpage (#PCDATA)>
46
47 <!-- New attributes -->
48 <!ENTITY % local.common.attrib
49 "debianversionequal CDATA #IMPLIED
50 debianversionmin CDATA #IMPLIED
51 debianversionmax CDATA #IMPLIED">
52
53
54 ]>
55
56 <article>
57
58 <artheader>
59 <title>The Debian SGML/XML HOWTO</title>
60 <author>
61 <firstname>St&eacute;phane</firstname>
62 <surname>Bortzmeyer</surname>
63 <affiliation>
64 <orgname>The Debian Project</orgname>
65 <address><email>bortzmeyer@debian.org</email></address>
66 </affiliation>
67 </author>
68 <othercredit>
69 <contrib>Spelling and grammar fixes</contrib>
70 <firstname>Guy</firstname>
71 <surname>Brand</surname>
72 <affiliation>
73 <address><email>guybrand@chimie.u-strasbg.fr</email></address>
74 </affiliation>
75 </othercredit>
76 <othercredit>
77 <contrib>Spelling, grammar and style fixes</contrib>
78 <firstname>John</firstname>
79 <surname>van der Koijk</surname>
80 <affiliation>
81 <address><email>jvdkoijk@wirehub.nl</email></address>
82 </affiliation>
83 </othercredit>
84 <releaseinfo>$Id: howto.db,v 1.3 1999-10-13 15:35:03 bortz Exp $</releaseinfo>
85 <copyright>
86 <year>1999</year>
87 <holder>St&eacute;phane Bortzmeyer</holder>
88 </copyright>
89 <legalnotice>
90 <para>This text is distributed according to the <ulink url="http://www.gnu.org/copyleft/gpl.html">General
91 Public License</ulink>.</para>
92 </legalnotice>
93 </artheader>
94
95 <sect1>
96 <title>Why this HOWTO? What's in it?</title>
97 <para>This section explains why this HOWTO exist and which people
98 it tries to help. It could be useful to read it first, before you
99 lose time.</para>
100 <sect2>
101 <title>What is in the HOWTO</title>
102 <para>This HOWTO contains <emphasis>practical</emphasis>
103 information about the use of SGML and XML on a Debian operating
104 system.</para>
105 <para>The HOWTO is task-oriented: you will see what Debian packages you will need for
106 various tasks, and how to use them. It is intended for hurried
107 people, who do not like to read and understand everything before
108 starting
109 and who prefers "hands on" training.
110 </para>
111 <para>We will cover SGML (and its subset XML), some DTD which I
112 find important and the tools to write, format and display SGML,
113 whether on the Web or in printing. The emphasis will be on SGML
114 as a way to write documentation, not as a general data
115 interchange tool.</para>
116 </sect2>
117 <sect2>
118 <title>What's not in the HOWTO</title>
119 <para>You will not find anything about installing and setting up
120 software, since we assume a Debian system, where everything is
121 already packaged. We will use only Debian packages, as they are
122 shipped with <phrase debianversionequal="2.2">Debian 2.2, nicknamed 'potato' (not yet ready when
123 writing this)</phrase><phrase debianversionequal="2.1">Debian 2.1, nicknamed
124 'slink'</phrase>.</para>
125 <para>This is not a tutorial on SGML or XML. Refer to
126 <xref linkend="references"/> for that type of information.
127 Instead, you will get just enough
128 SGML to get you started
129 right now.</para>
130 </sect2>
131 <sect2>
132 <title>Meta-information about this HOWTO</title>
133 <para>This HOWTO is itself written in DocBook (XML) on a Debian
134 system. The HOWTO can be retrieved from <ulink
135 url="http://www.debian.org/~bortz/SGML-HOWTO/">my Web
136 page</ulink>, including its <ulink
137 url="http://www.debian.org/~bortz/SGML-HOWTO/howto.db">source code</ulink>.</para>
138 </sect2>
139 <sect2>
140 <title>Why is this HOWTO specific to Debian?</title>
141 <para>I said the purpose was to start quickly, remember? This
142 means using actual filenames, actual commands and not wasting
143 time compiling <application>jade</application>. And I hate to insert "Your mileage way
144 vary" warnings everywhere. Therefore, I chose a specific
145 operating
146 system and I used the best one, <ulink
147 url="http://www.debian.org/">Debian</ulink>, which is also the
148 only one with an integrated SGML environment... Even if it is not
149 perfect, it works and, with this HOWTO, it even has a
150 documentation.</para>
151 <para>I added some pointers to <link linkend="otheros">other
152 operating systems</link>.</para>
153 </sect2>
154 </sect1>
155
156 <sect1>
157 <title>What you really need to know about SGML</title>
158 <para>I tried to keep this section short. However, I cannot
159 explain anything without a small basis of concepts about SGML. So,
160 let's go, before we switch to actual source code.</para>
161 <sect2>
162 <title>What is structured documentation?</title>
163 <para>Structured documentation is built upon structured elements:
164 chapters, sections, paragraphs, etcetera, where all elements
165 are clearly labeled for
166 what they are: references, program output, etc. No explicit information
167 about how the document should be rendered is given;
168 only about its structure (and content).
169 When there are explicit rules for presentation, they are kept
170 outside the SGML-document.</para>
171 <para>This allows for automatic processing of the documents, without
172 waiting for AI systems. It encourages authors to concentrate on
173 structure, which conveys meaning. </para>
174 <para>Thus, the question "How do I put a word in bold with
175 SGML?" has little relevance. One <emphasis>could</emphasis> ask
176 how to put emphasis on a certain stretch of text.</para>
177 </sect2>
178 <sect2>
179 <title>What is SGML?</title>
180 <para>Standard Generalized Markup Language is a standardized
181 language intended to facilitate the authoring of
182 structured documentation
183 <footnote><para>It has
184 other uses, such as data interchange.</para></footnote>. More
185 specifically, it is a meta-language. You never actually type
186 SGML, but SGML is used to describe
187 a document type specific structured language
188 (this is called a DTD, a Document Type
189 Definition), which defines how specific documants might be
190 structured (written).</para>
191 <para>Therefore, saying that a document is "in the SGML format"
192 is technically correct, but deceptive. One could say that a
193 document is in the DocBook format or the LinuxDoc format or the
194 TEI format.</para>
195 </sect2>
196
197 <sect2>
198 <title>What does SGML look like?</title>
199 <para>SGML is a markup language. All SGML documents include
200 text, mixed with <emphasis>tags</emphasis>, which delimits
201 <emphasis>elements</emphasis><footnote><para>Depending on the DTD, the
202 end-tag can be mandatory or not. In XML, end-tags are always mandatory.</para>
203 </footnote>. SGML allows several syntaxes to be
204 used, but we'll stick with the reference syntax, the most
205 common, where tags are enclosed between angle brackets, &lt; and
206 &gt;. Here is an example:</para>
207 <programlisting role="docbook">
208 <![CDATA[
209 <article>
210
211 <title>The Foo software</title>
212
213 <para>
214 Foo is very fast. And its documentation can be read easily.
215 </para>
216 ]]>
217 </programlisting>
218 <para>If it looks like HTML to you, it is because HTML is
219 (theoretically) a DTD of SGML.</para>
220 <para>Elements have a <emphasis>content</emphasis>. For
221 instance, the content of the above <sgmltag>para</sgmltag>
222 element is "Foo is very fast.
223 And its documentation can be read easily.".</para>
224 <para>Elements can have <emphasis>attributes</emphasis> to
225 indicate more information. For instance:</para>
226 <programlisting role="docbook">
227 <![CDATA[
228 <example tested="true">
229 *c++;
230 </example>
231 ]]>
232 </programlisting>
233 <para>You can have also <emphasis>entities</emphasis> which
234 allow you to parametrize some text. For instance, if you often
235 refer to "the Best Operating System, Debian" and you want to
236 avoid typing it each time or, worse, having to change every
237 occurrence if you finally decide a more modest wording, you
238 can declare an entity, let's call it "debian" and use it with
239 the ampersand "&amp;debian;"<footnote><para>This is
240 <emphasis>reference entities</emphasis>. SGML use other types
241 of entities, which are not covered in this HOWTO.</para></footnote>.</para>
242 <para> One element is special: the <emphasis>root
243 element</emphasis> is the global element, which contains
244 everything. In XML, the DOCTYPE line indicates which element
245 is the root. Here is an example<phrase debianversionequal="2.2"> (It
246 seems <emphasis>there is a bug</emphasis> in the SGML environment of Debian 2.2,
247 which requires a full path name for the DTD below. If so,
248 this is a bug and I will investigate it<comment>TODO: do
249 it, a bug against psgml has been filled. Follow it.</comment>)</phrase>:</para>
250 <programlisting role="docbook">
251 <![CDATA[
252 <!DOCTYPE article PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1//EN"
253 "dtd/docbook-xml/docbookx.dtd"[
254 ]]>
255 </programlisting>
256 <sect3><title>And the XML files?</title>
257 <para>You'll learn <link linkend="xml">later about
258 XML</link>. Let's just say that XML files begin first with a
259 <emphasis>processing instruction</emphasis>, which starts with
260 &lt;? and, in that case indicates it is a XML file, as well as
261 some meta-information. Example:</para>
262 <programlisting role="docbook">
263 <![CDATA[
264 <?xml version="1.0" encoding="utf-8"?>
265 ]]>
266 </programlisting>
267 <para>XML files must be <emphasis>well-formed</emphasis>,
268 which means that tags must be balanced (no crossing of tags
269 which is common in the HTML output of many Web editors) and
270 can be <emphasis>valid</emphasis> which means conformant to
271 their DTD.</para>
272 <para>Start-tags must always have an end-tag in XML, but you
273 can have <emphasis>empty elements</emphasis> where the
274 start-tag and the end-tag merge in a tag written with a / at
275 the end like:</para>
276 <programlisting role="xml">
277 <![CDATA[
278 <foobar/>
279 ]]>
280 </programlisting>
281 </sect3>
282 </sect2>
283
284 <sect2>
285 <title>What is a DTD?</title>
286 <para>A Document Type Definition is the description (in SGML)
287 of a specific language. You can write your own DTD (it is not
288 very difficult, especially in XML) or you can use an
289 already-existing DTD, which is convenient if you want to
290 exchange documents with other people. Several such DTDs exist,
291 typically for the purposes of a given group of people (astronoms, chemists, scholars in ancient literature...).</para>
292 <para>The DTD lists the allowed elements and their
293 relationships (for instance, it says a <sgmltag>chapter</sgmltag>
294 must have at least one <sgmltag>section</sgmltag>).</para>
295 <para>Typical DTDs that you may find useful:</para>
296 <itemizedlist>
297 <listitem>
298 <para><ulink url="http://www.oasis-open.org/docbook/">DocBook</ulink> is mostly intended for
299 writing technical documentation, especially about software.</para>
300 </listitem>
301 <listitem>
302 <para><ulink url="http://www.linuxdoc.org/">LinuxDoc</ulink>
303 is used by the Linux Documentation Project, for instance for
304 the Linux
305 HOWTOs. The LDP has decided to switch to DocBook, but the
306 conversion has not been carried out.</para>
307 </listitem>
308 <listitem>
309 <para><ulink url="http://www.debian.org/~elphick/ddp/manuals.html#doc">DebianDoc</ulink> is used in part by the
310 <ulink url="http://www.debian.org/~elphick/ddp/">Debian Documentation Project</ulink>.</para>
311 </listitem>
312 <listitem>
313 <para><ulink url="http://www.w3.org/MarkUp/">HTML</ulink> is
314 in theory an SGML DTD but
315 very few actual Web pages are compliant. So, most SGML tools
316 will choke on a typical Web page.</para>
317 </listitem>
318 </itemizedlist>
319 <para>At the beginning of a document, you will find a
320 reference to the DTD to use (there are several ways to indicate
321 such references; the following example is for LinuxDoc):</para>
322 <programlisting role="linuxdoc">
323 <![CDATA[
324 <!doctype linuxdoc system>
325
326 <article>
327
328 <title>The Linux Kernel HOWTO
329 ]]>
330 </programlisting>
331 <comment>TODO: Explain FPI, PUBLIC and SYSTEM, etc.</comment>
332 </sect2>
333
334 <sect2>
335 <title>Which DTD to choose?</title>
336 <para>Very often, you'll have no choice: the project you're a
337 part of will have chosen already. Since standardization is of
338 course very important in a big project, there is little chance
339 you'll be able to change that. For instance, Linux Documentation
340 Project uses LinuxDoc, <ulink
341 url="http://www.freebsd.org/docproj/docproj.html">FreeBSD</ulink>,
342 <ulink url="http://developer.gnome.org/arch/doc/tools.html">GNOME</ulink> or <ulink
343 url="http://www.kde.org/documentation/index.html">KDE</ulink> use DocBook, etc.</para>
344 <para>If you have the choice, I suggest to stay close to what
345 similar projects are doing. If you write technical documentation
346 for computer hardware or software, this probably means using
347 DocBook.</para>
348 </sect2>
349
350 <sect2>
351 <title>How do I write SGML?</title>
352 <para>Since SGML is a markup language, you can use any editor,
353 like <application>vi</application> or even
354 <application>cat</application>.</para>
355 <para>But it is often easier with an editor which helps you
356 inserting tags, knowing, for example, which are valid. I recommend
357 <application>Emacs</application> with its <link linkend="psgml">SGML mode</link>.</para>
358 </sect2>
359
360 <sect2 id="xml">
361 <title>What is XML?</title>
362 <para>XML (Extensible Markup Language ) is a subset of SGML, a
363 sort of SGML--. It
364 was designed first for the World-Wide Web, but it is now used
365 in unrelated areas.</para>
366 <para>XML is much simpler than SGML, with less options, so a parser is
367 lighter and faster.</para>
368 </sect2>
369
370 <sect2>
371 <title>What is a stylesheet?</title>
372 <para>In the markup world, you try to separate content from
373 presentation. Content is expressed in the SGML document,
374 following a given DTD. Presentation is expressed outside of the
375 document, typically in a DTD-specific stylesheet, which is a description, in an
376 appropriate language (<ulink
377 url="http://www.jclark.com/dsssl/">DSSSL
378 </ulink> - Document Style Semantics and
379 Specification Language - is the most common<footnote><para>The
380 XML world created a new language, <ulink
381 url="http://www.w3.org/Style/XSL/">XSL</ulink>, which has few
382 implementations at this moment<phrase debianversionmax="2.1">
383 (and none before Debian 2.2)</phrase>.
384 Despite what you may read in executive
385 summaries, it is perfectly acceptable to use DSSSL to render XML
386 files.</para></footnote>),
387 of the layout rules for documents written for a certain DTD.</para>
388 <para>For instance, it is the author of the stylesheet who will
389 decide that titles should be rendered in bold, that URLs will be
390 printed in red, etc.</para>
391 <para>If you know the <ulink url="http://www.w3.org/Style/css/">
392 CSS</ulink> (Cascading
393 Style Sheets) language, do note that typical languages for SGML
394 stylesheets are more complicated: they allow not only to specify
395 the rendering of an element, but also the reordering of elements,
396 computation of data from some elements, etc. DSSSL, for instance, is a
397 full blown programming language (based on Scheme), enriched with stylesheet
398 constructs.</para>
399 </sect2>
400
401 </sect1>
402
403 <sect1>
404 <title>Creating documentation with DocBook</title>
405 <para>Here, we will see how to write and process documentation,
406 using the DocBook DTD. We will use the XML version, often named
407 DocBk, because
408 I prefer XML<footnote><para>And also because future versions of
409 DocBook will be <ulink url="http://www.oasis-open.org/docbook/meetings/min19990308.html">XML</ulink>.</para></footnote>, but most of what is written here apply to the SGML
410 version as well.</para>
411 <para debianversionmax="2.1">To use it on a Debian system prior to
412 2.2 'potato', you'll need the
413 <debianpackage>docbook-xml</debianpackage>. It installs fine on a
414 'slink' system and does not break anything (it is just a DTD, it
415 does not depend on specific libraries).</para>
416 <sect2>
417 <title>Writing DocBook</title>
418 <para>You can skip this section if you just received a DocBook
419 file and want to process it, rather than edit it.</para>
420 <para>Like with any DTD, I recommend &psgml; to write DocBook. </para>
421 <para>First, choose a root element, preferably the simplest,
422 <sgmltag>article</sgmltag>. Start with:</para>
423 <programlisting role="docbook">
424 <![CDATA[
425 <?xml version="1.0"?>
426 <!DOCTYPE article PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1//EN"
427 "dtd/docbook-xml/docbookx.dtd">
428 <article>
429 <artheader>
430 <title>My first XML document</title>
431 </artheader>
432 <section>
433 <title>My first section</title>
434 <para>My first paragraph.</para>
435 </section>
436 </article>
437 ]]>
438 </programlisting>
439 <para>This is a complete DocBook document. You can <link linkend="nsgmls">
440 validate it</link>.</para>
441 <para>Typical DocBook documents use book, chapter or article as the
442 root element. Then, they include a header, where you find meta-information,
443 such as the title of the document. After this header, a DocBook
444 document is divided into sections, each with a title.
445 <comment>More details would be nice.</comment>
446 </para>
447 <para>To know the complete list of elements, see
448 <debiandoc text="the set of DocBook texts">docbook-doc</debiandoc>, more specially
449 <debiandoc file="r2333.html" text="DocBook DTD Reference">docbook-doc</debiandoc>.</para>
450 </sect2>
451
452 <sect2>
453 <title>Processing DocBook documents</title>
454 <para>Remember, DocBook is not a program but a format. Asking
455 "Does DocBook have a PDF output?" is meaningless. Software which
456 uses DocBook may produce PDF. DocBook itself does nothing.</para>
457 <para>There are several different solutions to produce printed
458 paper, Web pages or manual pages from DocBook documents. You could
459 program such a transformation yourself with tools like the Perl module
460 XML::Parser or the Java module XP. Or you can use stylesheets,
461 which you may or may not write yourself. If you decide not to
462 write them, you can use
463 the &modular_ss; with &jade;.</para>
464 <para>Since we are using the XML version of DocBook, here is how to
465 call &jade; to translate <filename>myfile.db</filename> to TeX:</para>
466 <programlisting role="shell">
467 jade -t tex \
468 -d &print_ss; \
469 &xml_decl; myfile.db
470 </programlisting>
471 <para>which will produce a TeX file using &jadetex; macros and
472 needing the &jadetex; program to be processed:</para>
473 <programlisting role="shell">
474 jadetex myfile.tex
475 </programlisting>
476 <para>And to HTML:</para>
477 <programlisting role="shell">
478 jade -t sgml \
479 -d &html_ss; \
480 &xml_decl; myfile.db
481 </programlisting>
482 <para>Unfortunately, there is no easy way to create text-only
483 output from a DocBook file, for instance for posting it on
484 Usenet. The best available solution is to use the following
485 kluge with
486 <application>lynx</application>:</para>
487 <programlisting role="shell">
488 jade -t sgml -V nochunks \
489 -d &html_ss; \
490 &xml_decl; myfile.db > dump.html
491 lynx -force_html -dump dump.html > myfile.txt
492 </programlisting>
493 <sect3 debianversionmin="2.2"><title>Using SGMLtools</title>
494 <para>You can also use &sgmltools2;. This may be
495 simpler, since &sgmltools2; automates the tasks performed by
496 jade, jadetex and lynx. But it does <emphasis>not</emphasis> work with the XML
497 version of DocBook. To convert a file to HTML:</para>
498 <programlisting role="shell">
499 sgmltools --backend=ps howto.db
500 </programlisting>
501 <para>And to PostScript:</para>
502 <programlisting role="shell">
503 sgmltools --backend=ps howto.db
504 </programlisting>
505 <para>And to pure text:</para>
506 <programlisting role="shell">
507 sgmltools --backend=txt howto.db
508 </programlisting>
509 </sect3>
510 <sect3><title>Automatize it with <application>make</application></title>
511 <para>Since the manipulations needed to convert from
512 DocBook to anything can be complicated, the use of
513 <application>make</application>
514 is recommended. An example of a <filename>Makefile</filename> is:</para>
515 <programlisting role="makefile">
516 <![CDATA[
517 MAX_TEX_RECURSION=4
518 XML_DECL=/usr/lib/sgml/declaration/xml.decl
519 HTML_SS=/usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/html/docbook.dsl
520 PRINT_SS=/usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/print/docbook.dsl
521
522 all: myfile
523
524 myfile: myfile.ps myfile.txt myfile.html
525
526 myfile.tex: myfile.db
527 jade -t tex \
528 -d $(PRINT_SS) \
529 $(XML_DECL) $<
530
531 myfile.dvi: myfile.tex
532 # Trick from Adam Di Carlo <adam@onshore.com> to recurse jadetex
533 # "just enough".
534 -cp -pf prior.aux pprior.aux
535 -cp -pf $(shell basename $< .tex).aux prior.aux
536 jadetex $<
537 if ! cmp $(shell basename $< .tex).aux prior.aux && \
538 ! cmp $(shell basename $< .tex).aux pprior.aux && \
539 expr $(MAKELEVEL) '<' $(MAX_TEX_RECURSION); then \
540 rm -f $@ ;\
541 $(MAKE) $@ ;\
542 fi
543 rm -f prior.aux pprior.aux
544
545 myfile.ps: myfile.dvi
546 dvips -f $< > $@
547
548 myfile.html: myfile.db html.dsl
549 jade -t sgml \
550 -d $(HTML_SS) \
551 $(XML_DECL) $<
552
553 myfile.txt: myfile.db
554 jade -t sgml -V nochunks \
555 -d $(HTML_SS) \
556 $(XML_DECL) $< > dump.html
557 lynx -force_html -dump dump.html > $@
558 -rm -f dump.html
559
560 validate:
561 nsgmls -s -wxml $(XML_DECL) myfile.db
562
563 clean:
564 rm -f *.html *.aux *.log *.dvi *.ps *.tex *.txt
565 ]]>
566 </programlisting>
567 </sect3>
568 <sect3 debianversionmin="2.2"><title>Misc</title>
569 <comment>TODO: localization in various languages.</comment>
570 <para>To convert DocBook to man pages or other formats, see <debianpackage name="docbook2X"
571 refserver="http://shell.ipoline.com/~elmert/hacks/docbook2X/">docbook2man</debianpackage>
572 and <debianpackage>docbook-to-man-ans</debianpackage>.
573 </para>
574 </sect3>
575 <sect3>
576 <title>Customizing the Modular DocBook Stylesheets</title>
577 <para>If you <link linkend="customdb">write a custom
578 element</link>
579 or if you want to change the default rendering of
580 an element or if you simply want to customize the output a bit
581 (such as changing the default font), you'll have to define a
582 custom stylesheet. This does not imply retyping everything.
583 DSSSL allows one stylesheet to "use" another. The stylesheet
584 inherits all of the properties of the stylesheet that it is
585 using, but local definitions take precedence over imported ones.
586 An example of a custom stylesheet is:</para>
587
588 <programlisting role="dsssl">
589 <![CDATA[
590
591 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
592 <!ENTITY docbook.dsl
593 PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"
594 CDATA DSSSL>
595 ]>
596
597 <style-sheet>
598 <style-specification use="docbook">
599 <style-specification-body>
600
601 (define %body-font-family%
602 ;; The font family used in body text
603 "Palatino")
604
605 </style-specification-body>
606 </style-specification>
607
608 <external-specification id="docbook" document="docbook.dsl">
609
610 </style-sheet>
611 ]]>
612 </programlisting>
613 <para>Your style instructions (here the changing of the font
614 to Palatino) have to be written in DSSSL, whose syntax and
615 many semantics come from the programming language Scheme,
616 which is itself a Lisp dialect. You do not need to learn
617 Scheme, the <phrase debianversionmax="2.1"><debiandoc text="documentation of the Modular Stylesheets" file="doc/custom.html">docbook-stylesheets</debiandoc></phrase><phrase debianversionmin="2.2"><debiandoc text="documentation of the Modular Stylesheets" file="custom.html">docbook-stylesheets-doc</debiandoc></phrase>
618 contains examples for most purposes.</para>
619 <para>Since there are actually two stylesheets, one for printing and
620 one for HTML, the above custom stylesheet works only for the
621 first one. For the second, here is an exemple:</para>
622 <programlisting role="dsssl">
623 <![CDATA[
624 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
625 <!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
626 ]>
627 <style-sheet>
628
629 <style-specification id="html" use="docbook">
630 <style-specification-body>
631
632 (define %generate-article-titlepage% #t)
633
634 </style-specification-body>
635 </style-specification>
636
637 <external-specification id="docbook" document="docbook.dsl">
638
639 </style-sheet>
640 ]]>
641 </programlisting>
642 <para>In both cases, you'll have to tell Jade to use your
643 stylesheets, here <filename>myprint.dsl</filename>:</para>
644 <programlisting role="shell">
645 jade -t tex \
646 -d myprint.dsl \
647 &xml_decl; myfile.db
648 </programlisting>
649
650 </sect3>
651 <sect3 id="customdb"><title>Customizing the DocBook DTD</title>
652 <para>
653 DocBook is intended to be customizable. There are many ways
654 to do that<footnote><para>Including copying the DTD and
655 editing it... But I was referring to `clean' ways of modifying the
656 DTD, which will not create too many problems with
657 future versions of DocBook.</para></footnote>,
658 but be careful: customization may lead to problems
659 when exchanging documents with others. See <debiandoc
660 text="Customizer's Guide for the DocBook DTD" file="book68527.html">docbook-doc</debiandoc>.
661 </para>
662 <para>If you add new elements, you'll probably have to
663 create a custom stylesheet as well.</para>
664 <comment>
665 Give examples of customization.
666 </comment>
667 </sect3>
668 </sect2>
669
670 </sect1>
671
672 <sect1>
673 <title>Creating documentation with LinuxDoc</title>
674 <para>We will now go into writing and processing documentation
675 using the LinuxDoc DTD.</para>
676 <sect2>
677 <title>Writing LinuxDoc</title>
678 <para>You can skip this section if you just received a LinuxDoc
679 file (for instance one of the Linux HOWTOs, such as you can find in the
680 <ulink
681 url="http://metalab.unc.edu/pub/Linux/docs/HOWTO/other-formats/sgml/">
682 LinuxDoc servers</ulink>).</para>
683 <para>You may write LinuxDoc documents with &psgml;. Here is a
684 sample example:</para>
685 <programlisting role="linuxdoc">
686 <![CDATA[
687 <!doctype linuxdoc system>
688 <article>
689
690 <title>Quick SGML Example
691 <author>Matt Welsh, <tt>mdw@cs.cornell.edu</tt>
692 <date>v1.0, 28 March 1994
693 <abstract>
694 This document is a brief example using the Linuxdoc-SGML DTD.
695 </abstract>
696
697 <sect>Introduction
698
699 <p>
700 This is an SGML example file using the Linuxdoc-SGML DTD.
701
702 </article>
703 ]]>
704 </programlisting>
705 <para>A more complete example of a LinuxDoc document is <debiandoc file="example.sgml.gz">sgml-tools</debiandoc>.</para>
706 <para>To learn the list of legal elements, see <debiandoc
707 file="html/guide.html.gz">sgml-tools</debiandoc><phrase
708 debianversionmax="2.2"> (it is currently buggy: the HTML files
709 are compressed, which may harm your browser) </phrase><comment>TODO Does it
710 work? It seems HTML files are gzipped :-( Fill in a bug report</comment>or see <ulink
711 url="http://www.sgmltools.org/guide/guide.html">Matt Welsh's guide</ulink>.</para>
712 </sect2>
713 <sect2>
714 <title>Processing LinuxDoc</title>
715 <para>You will use &sgmltools1;. To convert a
716 LinuxDoc document to HTML:</para>
717 <programlisting role="shell">
718 sgml2html document.sgml
719 </programlisting>
720 <para>To ordinary text, for instance to post it on the News:</para>
721 <programlisting role="shell">
722 sgml2txt document.sgml
723 </programlisting>
724 <para>And to PostScript, using LaTeX:</para>
725 <programlisting role="shell">
726 sgml2latex --output=ps document.sgml
727 </programlisting>
728 <comment>
729 The extension has to be .sgml or sgml-tools will do unproper
730 things.
731 </comment >
732 <para>You can have more information in <phrase
733 debianversionmax="2.1">sgmltools(1)</phrase><phrase debianversionmin="2.2">sgmltools.v1(1)</phrase>.</para>
734 <comment>TODO: localization un various languages.</comment>
735 </sect2>
736
737 </sect1>
738
739 <sect1>
740 <title>Creating documentation with DebianDoc</title>
741 <para>Here, we will see how to write and process documentation,
742 using the DebianDoc DTD.</para>
743 <sect2><title>Writing DebianDoc documents</title>
744 <para>Here is a sample DebianDoc document:</para>
745 <programlisting role="debiandoc">
746 <![CDATA[
747 <!doctype debiandoc public "-//DebianDoc//DTD DebianDoc//EN">
748
749 <debiandoc>
750 <book>
751 <titlepag>
752 <title>FooBar</title>
753 <author>
754 <name>Bortzmeyer</name>
755 <email>bortzmeyer@debian.org</email>
756 </author>
757 </titlepag>
758 <chapt>
759 <heading>Title</heading>
760 <p>Content</p>
761 </chapt>
762 </book>
763 </debiandoc>
764 ]]>
765 </programlisting>
766 <para>To know the list of legal tags, see <phrase
767 debianversionmax="2.1">
768 <debiandoc
769 file="debiandoc-sgml.html/index.html">debiandoc-sgml</debiandoc>
770 </phrase>
771 <phrase debianversionmin="2.2"><debiandoc
772 file="debiandoc-sgml.html/index.html">debiandoc-sgml-doc</debiandoc>
773 <comment>Bug #47300</comment></phrase>.</para>
774 </sect2>
775 <sect2><title>Processing DebianDoc documents</title>
776 <para>
777 To translate to PostScript:
778 </para>
779 <programlisting role="shell">
780 debiandoc2ps -1 myfile.dd
781 </programlisting>
782 <para>And to HTML:</para>
783 <programlisting role="shell">
784 debiandoc2html myfile.dd
785 </programlisting>
786 </sect2>
787
788 </sect1>
789
790 <sect1>
791 <title>Tools</title>
792 <para>This section is no longer oriented toward tasks, but toward
793 software that you can use to write and process SGML.</para>
794 <para debianversionmin="2.2"> The simplest way to
795 get all these tools is to install
796 <debianpackage>task-sgml</debianpackage>.</para>
797 <para debianversionmax="2.1"> To get all these tools, you'll have to
798 install several packages. Here is the
799 <application>apt</application> command which will do it for
800 you<footnote><para>Providing that <application>apt</application>
801 has been configured properly before.</para></footnote>:
802 <programlisting role="shell">
803 apt-get install docbook docbook-doc sp jade \
804 docbook-stylesheets jadetex debiandoc-sgml \
805 psgml
806 </programlisting>
807 </para>
808 <sect2 id="psgml">
809 <title><debianpackage name="psgml" refserver="http://www.lysator.liu.se/projects/about_psgml.html">PSGML</debianpackage></title>
810 <para>An excellent SGML mode for Emacs. Among its many features,
811 it can:</para>
812 <itemizedlist>
813 <listitem><para>Show you what tags are valid at a given point,</para>
814 </listitem>
815 <listitem><para>Insert tags (begin and end, as well as
816 mandatory tags in between) from a menu which shows only valid
817 tags (this is tremendously useful when you start to use a new
818 and complicated DTD),</para>
819 </listitem>
820 <listitem><para>Manipulate SGML elements, move
821 according to elements, etc.</para>
822 </listitem>
823 </itemizedlist>
824 <para>Its documentation is in <debiandoc
825 file="psgml_toc.html">psgml</debiandoc>.</para>
826 <para>
827 Having some options set up in your <filename>~/.emacs</filename> will
828 ease your use of psgml. Here are some examples:</para>
829 <programlisting role="emacs-lisp">
830 <![CDATA[
831 (autoload 'xml-mode "psgml" "Major mode to edit XML files." t )
832
833 (setq
834 auto-mode-alist (append '(
835 ;; DocBook-XML
836 ("\\.db" . xml-mode)
837 )
838 auto-mode-alist))
839
840 (add-hook 'sgml-mode-hook 'turn-on-auto-fill)
841 (setq sgml-custom-dtd '(
842 ( "HTML 4.0 Strict"
843 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"
844 \"dtd/html-4.0s.dtd\">" )
845 ( "HTML 4.0 Blaireau"
846 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional 4.0//EN\"
847 \"dtd/html-4.0-loose.dtd\">" )
848 ( "DocBook 3.1 XML Article"
849 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
850 <!DOCTYPE article PUBLIC \"-//Norman Walsh//DTD DocBk XML V3.1//EN\"
851 \"dtd/docbook-xml/docbookx.dtd\">" )
852 ))
853 (setq sgml-insert-missing-element-comment nil)
854 ]]>
855 </programlisting>
856 <para>Among the most useful psgml commands:
857 <itemizedlist>
858 <listitem><para>C-c C-t :
859 <command>sgml-list-valid-tags</command>
860 reminds you
861 (or teaches you) the DTD. Very convenient when you start
862 playing with a monster like DocBook.</para>
863 </listitem>
864 <listitem><para><command>sgml-insert-element</command>. Again, a great
865 way to learn a DTD</para>
866 </listitem>
867 </itemizedlist>
868 </para>
869 </sect2>
870 <sect2 id="nsgmls">
871 <title><debianpackage name="sp" refserver="http://www.jclark.com/sp/nsgmls.htm">nsgmls</debianpackage></title>
872 <para>An SGML tool, for instance for validating SGML documents. A
873 typical use is to check the validity of a document:</para>
874 <programlisting role="shell">
875 nsgmls -s file.sgml
876 </programlisting>
877 <para>This will check whether or not the contents of the file
878 <filename>file.sgml</filename> conform to the DTD indicated
879 in the header of the file.</para>
880 <para>If you write XML documents, two options of nsgmls are
881 necessary:</para>
882 <programlisting role="shell">
883 nsgmls -s -wxml &xml_decl; file.sgml
884 </programlisting>
885 <para>There is a <debiandoc
886 file="nsgmls.htm">sp</debiandoc>. nsgmls being a part of the
887 sp package, the <debiandoc file="index.htm">sp</debiandoc> for sp may be useful
888 too.</para>
889 </sect2>
890 <sect2 id="rxp" debianversionmin="2.2">
891 <title><debianpackage>rxp</debianpackage></title>
892 <para>A pure XML tool; can, for instance, be used to validate XML
893 documents.</para>
894 </sect2>
895 <sect2 id="jade">
896 <title><debianpackage
897 refserver="http://www.jclark.com/jade/">jade</debianpackage></title>
898 <comment>TODO: We should mention OpenJade! http://jade-cvs.avionitek.com/</comment>
899 <para>jade is a DSSSL
900 processor. It takes an SGML file and a
901 stylesheet, written in the DSSSL language, and produces output
902 in the TeX (for which PostScript can be made), RTF or HTML
903 formats.
904 It has
905 no backend for <application>groff</application> and therefore has trouble producing
906 ASCII. The <application>TeX</application> backend produces &jadetex; files.</para>
907 <para>The documentation is not really clear but it at leasts
908 tell you the various options. See <debiandoc file="jade.htm">jade</debiandoc>.</para>
909 <para>Typical uses:</para>
910 <programlisting role="shell">
911 jade -t backend-to-use -d stylesheet-name input-file
912 </programlisting>
913 </sect2>
914 <sect2 id="jadetex">
915 <title><debianpackage>jadetex</debianpackage></title>
916 <comment>http://www.tug.org/applications/jadetex/"</comment>
917 <para>A set of <application>TeX</application> macros to process
918 the output of jade. Poorly documented and difficult to
919 customize. Like with every TeX macros, several runs may be
920 necessary, in particular to resolve references.</para>
921 </sect2>
922 <sect2 id="sgmltools2" debianversionmin="2.2">
923 <title><debianpackage name="sgmltoolsv2" refserver="http://www.sgmltools.org/">SGMLtools</debianpackage></title>
924 <para>The SGMLtools exist in two versions, 1 and 2. SGMLtools is
925 the version 2.</para>
926 <para>Unlike sgml-tools, version 1, which processes LinuxDoc
927 documents, SGMLtools, version 2, treats DocBook
928 documents. You can do everything it does with direct calls
929 to &jade; but it may be simpler to use SGMLtools.</para>
930 </sect2>
931 <sect2 id="sgmltools1">
932 <title><debianpackage name="sgml-tools"
933 refserver="http://www.sgmltools.org/download-1.0.html">sgml-tools,
934 version 1</debianpackage></title>
935 <para>
936 <footnote debianversionmin="2.2"><para>Did you notice the change in the
937 capitalization?</para></footnote>
938 This version is officially deprecated and should no
939 longer, in theory, be used anymore. But, in practice, since
940 the move of the Linux Documentation Project from LinuxDoc to
941 the DocBook DTD never occured, you still need sgml-tools
942 version 1.</para>
943 </sect2>
944 <sect2 id="modularss">
945 <title><debianpackage name="docbook-stylesheets"
946 refserver="http://www.nwalsh.com/docbook/dsssl/index.html">
947 Norman Walsh's "DocBook Modular Stylesheets"</debianpackage></title>
948 <para>These are a set of DSSSL stylesheets (with a recent XSL version). You
949 can use them with any DSSSL tool, like &jade; to process DocBook documents.</para>
950 </sect2>
951 </sect1>
952
953 <sect1 id="references">
954 <title>References</title>
955 <itemizedlist>
956 <listitem>
957 <para>SGML in general</para>
958 <itemizedlist>
959 <listitem>
960 <para><ulink
961 url="http://www.oasis-open.org/cover/">Cover's
962 page</ulink></para>
963 </listitem>
964 <listitem>
965 <para><ulink
966 url="http://www-tei.uic.edu/orgs/tei/sgml/teip3sg/index.html">
967 A Gentle Introduction to SGML</ulink> by the TEI people. Not very
968 practical, IMHO. <comment>TODO: read it again, Sam.</comment>
969 </para>
970 </listitem>
971 </itemizedlist>
972 </listitem>
973 <listitem>
974 <para>XML in general</para>
975 <itemizedlist>
976 <listitem>
977 <para><ulink
978 url="http://www.w3.org/XML/">Official XML</ulink></para>
979 </listitem>
980 <listitem>
981 <para><ulink
982 url="http://www.oasis-open.org/cover/xml.html">Cover's XML
983 page</ulink></para>
984 </listitem>
985 <listitem>
986 <para><ulink
987 url="http://www.ucc.ie/xml/">XML FAQ</ulink></para>
988 </listitem>
989 </itemizedlist>
990 </listitem>
991 <listitem>
992 <para>DocBook</para>
993 <itemizedlist>
994 <listitem>
995 <para><ulink url="http://www.oasis-open.org/docbook/">Official
996 DocBook</ulink></para>
997 </listitem>
998 <listitem>
999 <para><debiandoc file="index.html">docbook-doc</debiandoc></para>
1000 </listitem>
1001 <listitem>
1002 <para><ulink url="http://www.nwalsh.com/docbook/dsssl/">
1003 Modular DocBook Stylesheets</ulink></para>
1004 </listitem>
1005 <listitem>
1006 <para><ulink url="http://www.freebsd.org/tutorials/docproj-primer/">
1007 FreeBSD Documentation Project Primer</ulink> is a nice introduction to
1008 SGML and
1009 DocBook</para>
1010 </listitem>
1011 <listitem>
1012 <para><ulink
1013 url="http://www.nwalsh.com/docbook/simple/sdocbook/">
1014 Simplified DocBook</ulink>, a version of DocBook with
1015 less elements to learn</para>
1016 </listitem>
1017 </itemizedlist>
1018 </listitem>
1019 <listitem>
1020 <para>LinuxDoc</para>
1021 <itemizedlist>
1022 <listitem>
1023 <para><ulink
1024 url="http://www.sgmltools.org/guide/guide.html">Matt
1025 Welsh's SGML-Tools User's Guide</ulink></para>
1026 </listitem>
1027 </itemizedlist>
1028 </listitem>
1029 <listitem id="otheros">
1030 <para>Other operating systems: this section will list
1031 documents similar to this HOWTO (I mean
1032 <emphasis>practical</emphasis> documents) for operating systems
1033 other than Debian.</para>
1034 <itemizedlist>
1035 <listitem>
1036 <para><ulink
1037 url="http://ourworld.compuserve.com/homepages/hoenicka_markus/ntsgml.html">Microsoft
1038 Windows NT</ulink></para>
1039 </listitem>
1040 <listitem>
1041 <para>RedHat users of DocBook should probably <ulink
1042 url="http://sourceware.cygnus.com/docbook-tools/">see the
1043 Cygnus tools</ulink>.</para>
1044 </listitem>
1045 </itemizedlist>
1046 </listitem>
1047 </itemizedlist>
1048 <bibliography>
1049 <title>Interesting books</title>
1050 <biblioentry>
1051 <bookbiblio>
1052 <title>SGML CD</title>
1053 <author>
1054 <surname>DuCHARME</surname>
1055 <firstname>Bob</firstname>
1056 </author>
1057 <editor>
1058 <surname>Prentice-Hall</surname>
1059 </editor>
1060 <isbn>0-13-475740-8</isbn>
1061 <abstract>
1062 <para>A very good and practical book about the tools
1063 needed to write and process SGML on Unix and Windows
1064 NT. Does not cover XML.</para>
1065 </abstract>
1066 </bookbiblio>
1067 <bookbiblio>
1068 <title>DocBook: The Definitive Guide</title>
1069 <author>
1070 <surname>Walsh</surname>
1071 <firstname>Norman</firstname>
1072 </author>
1073 <author>
1074 <surname>Muellner</surname>
1075 <firstname>Leonard</firstname>
1076 </author>
1077 <editor>
1078 <surname>O'Reilly</surname>
1079 </editor>
1080 <isbn>1-56592-580-7</isbn>
1081 <abstract>
1082 <para>I didn't read it yet...</para>
1083 </abstract>
1084 </bookbiblio>
1085 </biblioentry>
1086 </bibliography>
1087 </sect1>
1088 </article>
1089
1090
1091
1092

  ViewVC Help
Powered by ViewVC 1.1.5