DocBook Installatie mini-HOWTO

Robert B Easter

Vertaald door:Ellen Bokhorst

Revision History
Revision v1.804-02-2002Revised by: rbe

De DocBook-Install-mini-HOWTO is een gedetailleerde praktische handleiding voor nieuwelingen om snel DocBook geïnstalleerd te krijgen om SGML bestanden in HTML, PS en PDF bestanden om te kunnen zetten op een GNU/Linux systeem - andere systemen kunnen vergelijkbaar zijn. Aangezien er voor de setup van DocBook bestanden nodig zijn vanuit verscheidene apart gedistribueerde packages, kan het voor beginners verwarrend zijn.


Table of Contents
Introductie
Download de Packages
Installeer de packages
Gebruiken van DocBook
A. Legal
B. GNU Free Documentation License

Introductie

Informatie over dit document

De laatste versie van deze mini-HOWTO is te vinden op:

http://www.linuxdoc.org/HOWTO/mini/DocBook-Install/

Zie de "Legal" sectie in de appendix voor het copyright, de licentie en disclaimer informatie betrekking hebbend op dit document.


Wat is DocBook

DocBook is een Standard Generalized Markup Language (SGML) Document Type Definition (DTD) waarin een set tekstuele document markup tags wordt gedefinieerd die veel lijkt op de bekende HTML taal die op het web wordt toegepast.

DocBook is bedoeld voor het bewerken van boeken en artikelen. Als zodanig voorziet het in tags die specifiek zijn ontworpen voor het schrijven van boeken en artikelen. De <book> en en <article> DocBook tags bijvoorbeeld worden gebruikt om boeken en artikelen aan te maken. Binnen deze documenten worden de <chapter>, <sect1>, en <para> tags gebruikt. DocBook SGML bestanden worden opgeslagen in tekstbestanden met een sgml of gml toevoegsel.

Wanneer het wordt verwerkt, kan een enkel DocBook SGML bestand als uitvoer html, pdf, ps, txt en andere formaten voor zowel online als gedrukte publicatie opleveren. De verwerking wordt bepaald door stylesheets die automatisch inhoudsopgaves, paginanummeringen, hoofdstuk- & en sectienummeringen en andere features kunnen genereren.

DocBook is ook ontworpen voor het bewerken van unix man pages door het schrijven van <refentry> documenten. Probeer de opdracht man man vanachter je terminal als je niet weet wat een man page is.


Beknopt overzicht

Hier zijn beknopte beschrijvingen van de packages waarmee we in de volgende secties zullen gaan werken:

OpenJade. OpenJade is een implementatie van de ISO/IEC 10179:1996 internationale standaard Document Style Semantics and Specification Language (DSSSL). OpenJade voert de DSSSL taal uit om SGML en XML invoerbestanden te verwerken. In het bijzonder maakt het gebruik van de Modulaire DocBook Stylesheets dsl code om DocBook SGML/XML bestanden om te zetten naar andere formaten zoals html, tex, rtf, txt en anderen. OpenJade is de essentiële engine voor het omzetten van een DocBook bestand naar andere formaten. Het TeX uitvoerformaat wordt meestal gebruikt als een tussenliggend formaat om dvi, pdf, en ps via TeX macros en dvi converters te kunnen verkrijgen.

DocBook SGML DTD. De DocBook Document Type Definition (DTD) bestanden zijn SGML bestanden die de DocBook taal definiëren. Het definieert de geldige set met tags en regels voor gebruik. OpenJade vereist toegang tot de DTD bestanden voor elk type document dat het verwerkt.

ISO8879 ENTITY SGML. Entiteiten definiëren hoe speciale tekens worden voorgesteld die of niet op het toetsenbord voorkomen of een speciale betekenis hebben in SGML. Voorbeelden bekend vanuit HTML zijn o.a. "&amp;"='&', "&gt;"='>', en "&lt;"='<'.

DocBook DSSSL (Modular DocBook Stylesheets). De DSSSL bestanden (met de extensie dsl) voor een bepaalde DTD, in dit geval DocBook, specificeren hoe DocBook naar html, rtf, tex, enz te converteren. Een dsl bestand is invoer voor openjade in combinatie met je DocBook sgml bestand en het vertelt openjade hoe je document in een ander bestandsformaat te transformeren/stijleren. De dsl voor online (html) formaten is vaak anders dan voor af te drukken (dvi, pdf, ps) formaten.

SGMLtools-Lite. SGMLtools-Lite is een frontend wrapper voor het uitvoeren van openjade en de TeX macro's jadetex en pdfjadetex, macro's die in OpenJade zijn opgenomen. Het converteren van een DocBook bestand naar ps of pdf is een proces bestaande uit twee of drie stappen. OpenJade geeft als uitvoer een tex bestand wat weer de invoer is voor jadetex om een dvi bestand te kunnen produceren en pdfjadetex om een pdf bestand te kunnen produceren. Een ps bestand wordt verkregen door het dvi bestand door te geven aan dvips. Het sgmltools script voorziet in een enkele opdracht om deze taken uit te voeren.

HTMLdoc. HTMLdoc is een vrij programma voor het omzetten van html bestanden naar een pdf of ps bestand.

SGMLSpm en docbook2X. Samen worden deze gebruikt om man pages te genereren. SGMLSpm is een perl5 module library voor het verder verwerken van verwerkte uitvoer van onsgmls, een programma dat met OpenJade wordt meegeleverd. In SGMLSpm is een applicatie genaamd sgmlspl opgenomen voor gebruik van de SGMLSpm library. Voor Sgmlspl zijn "spec files" nodig, die van diverse bronnen op Internet beschikbaar zijn, voor elk type uit te voeren documentomzetting. DocBook2X is een package dat voorziet in de spec files voor het omzetten van de DocBook bestanden in man pages.


Download de Packages

In deze sectie zullen we de software op het Internet lokaliseren en downloaden.


OpenJade

OpenJade is een actief onderhouden open-source softwareproject gebaseerd op het Jade Package van James Clark. Download de laatste stabiele release vanaf:

http://openjade.sourceforge.net/

In OpenJade is ook het OpenSP package opgenomen en de TeX macro's, jadetex en pdfjadetex voor het omzetten van bestanden naar dvi en pdf. De volgende programma's worden door dit package geleverd:

  • openjade

  • onsgmls

  • osgmlnorm

  • ospam

  • ospent

  • osx

Voor gebruik van jadetex en pdfjadetex om dvi ps, en pdf aan te kunnen maken, moet je een werkende TeX (tex) installatie hebben. Als je TeX niet hebt, kijk dan in je Linux distributie voor een binair package dat kan worden opgehaald en geïnstalleerd. Anders kun je de teTeX distributie van TeX downloaden vanaf:

http://www.tug.org/tetex/


DocBook SGML DTD

De DocBook DTD voor SGML en XML wordt onderhouden door een technisch commitee op Oasis-Open.ORG. Download de huidige versie (en eventuele oudere versies die je wellicht nodig hebt) van DocBook SGML vanaf:

http://www.oasis-open.org/docbook/sgml/index.shtml


ISO8879 ENTITY SGML

De entiteiten definiëren representaties voor speciale of niet te typen symbolen of tekens, waaronder wiskundige symbolen, en de entiteiten die je wellicht kent van HTML. Deze bestanden moeten voor een juiste configuratie worden geïnstalleerd.

ISOEnts.zip kan simpelweg met unzip worden uitgepakt in de directory waar de DocBook DTD is uitgepakt zonder dat er iets anders nodig is, behalve het bestand isoENT-tar.gz. Ook de bestanden in isoENT-tar.gz kunnen worden uitgepakt in de directory met de DocBook DTD bestanden (zie de volgende sectie over het installeren voor meer details). Deze bestandsnamen eindigen op de extensie ".ent". Deze zullen moeten worden hernoemd naar een ".gml" toevoegsel. Je kunt dit handmatig doen, of je kunt het onderstaande bestand gebruiken, gemaakt door de auteur, waarin de bestanden van zowel ISOEnts.zip als isoENT-tar.gz zijn opgenomen:

http://reaster.com/iso8879-entities.tar.gz


DocBook DSSSL

Norman Walsh's Document Style Semantics and Specification Language (DSSSL) bestanden voor de DocBook DTD (SGML/XML) worden onderhouden in de DocBook Open Repository op SourceForge. Deze bestanden, ook bekend als de Modulaire DocBook Stylesheets, vertellen openjade wat het moet doen bij het converteren van je DocBook SGML bestand naar andere formaten. Een dsl bestand specificeert ook zaken zoals de herindelingen van de tags van de ene DTD naar die van een andere DTD en overige programmatische conversies, geprogrammeerd in de DSSSL taal. De DSSSL taal is samengesteld uit een groep verschillende talen, maar overal doorheen de Core Expression Language welke is gebaseerd op Scheme.

Het DocBook DSSSL package en de bijbehorende documentatie kan worden gedownload vanaf de site van het DocBook DSSSL Stylesheets Project

Het Linux Documentatie Project heeft een bestand met daarin aanpassingen op de stylesheet waarin een aantal fraaie stijlfeatures zijn aangezet. Het kan worden gedownload vanaf:

http://www.linuxdoc.org/authors/tools/ldp.dsl


SGMLtools-Lite

SGMLtools-Lite is een frontend voor openjade, jadetex, pdfjadex, dvips, en andere programma's. Het voorziet in een enkele opdracht voor het genereren van alle mogelijke formaten met deze tools. De laatste release kan worden gedownload vanaf:

http://sourceforge.net/projects/sgmltools-lite/

Dit package is optioneel, maar maakt het er soms wat gemakkelijker op.


HTMLdoc

HTMLdoc is een vrij verkrijgbaar programma voor het omzetten van websites in het Portable Document Formaat (pdf) of PostScript (ps). Voor pdf, maakt het een structuur met bookmarks aan die de navigatie vergemakkelijken. Zowel htmldoc als pdfjadetex geeft als uitvoer pdf bestanden, maar in een iets ander formaat. Probeer beiden en kijk welke het beste resultaat oplevert voor een bepaald docbook bestand. Zie wat links hieronder voor de site waar het kan worden gedownload.

Je kunt de laatste versie van HTMLdoc downloaden vanaf Easy Software Products' ftp site.


DocBook2X

Voor DocBook2X heb je perl5 en de SGMLS.pm perlmodule nodig, die beschikbaar zijn bij het Comprehensive Perl Archive Network (CPAN). SGMLS.pm voorziet in library's en een programma genaamd sgmlspl die DocBook bestanden omzet naar andere formaten door gebruik te maken van spec files. De spec files zijn perlbestanden die voorzien in de logica voor de omzetting naar een bepaald formaat.

http://www.cpan.org/

http://docbook2x.sourceforge.net/


Installeer de packages

Voor de installatie

In de volgende secties worden suggesties gedaan voor hoe je de gedownloade packages wellicht zou kunnen installeren om je DocBook SGML omgeving op te zetten. Het kan zijn dat de voorbeelden verwijzen naar oude versies van de packages, maar je zou ze in plaats daarvan zo aan moeten passen dat je de meest recente versies gebruikt.

Voor de meest bijgewerkte, authoratieve informatie moet je altijd de documentatie lezen die met een package dat je gaat installeren wordt meegeleverd. Vaak zul je een README en een INSTALL bestand aantreffen als je het archief hebt uitgepakt.

De gedetailleerde instructies hieronder werken wellicht niet exact zoals weergegeven, aangezien packages voortdurend aan wijzigingen onderhevig zijn. De instructies zouden je echter een algemeen idee kunnen geven van de procedure om DocBook SGML werkend te krijgen.


Installeer OpenJade

openjade

Hieronder staat wat je moet doen, maar denk eraan de bestanden te lezen die met Openjade werden meegeleverd om erachter te komen of er iets speciaals moet worden gedaan voor je platform:

cd /usr/local
tar -xvzf ~/openjade-1.3.tar.gz
cd openjade-1.3
./configure --prefix=/usr/local/openjade-1.3
make
make install

# Eenmaal geïnstalleerd, kunnen de objecten, enz worden
# verwijderd.
make clean

De installatie plaatst library's in /usr/local/openjade-1.3/lib, dus wellicht dat je ze graag toe wilt voegen aan /etc/ld.so.conf en ldconfig uit wilt voeren. Voeg /usr/local/openjade-1.3/bin toe aan je $PATH.

Wellicht dat je je afvraagt waarom ik de openjade source directory in /usr/local dump. De auteur ervaarde het een en ander bij de installatie van openjade. Bij nieuwere releases van OpenJade echter, zou je een standaard (/usr/local/src) lokatie voor het openjade source package kunnen proberen met een ander voorvoegsel als installatielokatie, en zien hoe dat gaat.


jadetex & pdfjadetex

Zoals vermeld zijn jadetex en pdfjadetex TeX macro's die met OpenJade worden verpakt. Ze zijn te vinden in /usr/local/openjade-3.1/dsssl. Een handige handleiding om deze macro's te installeren werd voorbereid door Frank Atanassow Christoph en het is te vinden op:

ftp://ftp.dante.de/tex-archive/macros/jadetex/install.pdf

http://reaster.com/installjadetex.pdf

Het volgende is gebaseerd op de instructies in install.pdf:


Maak (zonodig) hugelatex aan

De texmacros jadetex en pdfjadetex vereisen meer geheugen dan een reguliere uitvoering van tex. De standaard geheugenlimietconfiguratie van tex is vaak te beperkt. Het tex configuratiebestand texmf.cnf kan worden gewijzigd en de variabelen die het geheugengebruik van tex beperken kan worden verhoogd. Maar in plaats van gewoon het bestand texmf.cnf te wijzigen waardoor tex onder alle omstandigheden meer geheugen heeft, kan een aangepaste tex context worden gecreërd, genaamd hugelatex. Als hugelatex reeds op je systeem is geconfigureerd, dan kun je deze subsectie overslaan (which hugelatex).

Verifieer dat een werkende TeX is geïnstalleerd en het zijn directory kan vinden:
bash$ which tex
/usr/share/texmf/bin/tex
bash$ kpsewhich -expand-var='$TEXMFMAIN'
/usr/share/texmf
bash$

Het gebruik van which zou de lokatie van het programma tex moeten lokaliseren. Als het niet wordt gevonden, dan moet je teTeX wellicht nog installeren en daarna hiernaar toe terugkeren. kpsewhich is een utility dat met teTeX wordt meegeleverd en dat de main tex directory weet te lokaliseren als alles goed gaat.

Nu de directory texmf bekend is, kan de installatie beginnen:

cd /usr/share/texmf
cd tex/latex
cp -r config config-temp
cd config-temp
tex -ini -progname=hugelatex latex.ini
mv latex.fmt hugelatex.fmt
mv hugelatex.fmt /usr/share/texmf/web2c
cd ..
rm -r config-temp
cd /usr/share/texmf/bin
ln -s tex hugelatex
cd /usr/share/texmf/web2c

De web2c directory bevat het configuratiebestand texmf.cnf. Maak een backup van dit bestand: cp texmf.cnf texmf.cnf.orig. Wijzig het bestand met een editor naar keuze en voeg de volgende regels aan het einde van het bestand toe:

% hugelatex settings
extra_mem_top.hugelatex = 8000000
extra_mem_bot.hugelatex = 8000000
hash_extra.hugelatex = 15000
pool_size.hugelatex = 5000000
string_vacancies.hugelatex = 45000
max_strings.hugelatex = 55000
pool_free.hugelatex = 47500
nest_size.hugelatex = 500
param_size.hugelatex = 1500
save_size.hugelatex = 5000
stack_size.hugelatex = 15000

% jadetex
extra_mem_top.jadetex = 8000000
extra_mem_bot.jadetex = 8000000
hash_extra.jadetex = 20000
pool_size.jadetex = 5000000
string_vacancies.jadetex = 45000
max_strings.jadetex = 55000
pool_free.jadetex = 47500
nest_size.jadetex = 500
param_size.jadetex = 1500
save_size.jadetex = 5000
stack_size.jadetex = 15000

% pdfjadetex
extra_mem_top.pdfjadetex = 8000000
extra_mem_bot.pdfjadetex = 8000000
hash_extra.pdfjadetex = 20000
pool_size.pdfjadetex = 5000000
string_vacancies.pdfjadetex = 45000
max_strings.pdfjadetex = 55000
pool_free.pdfjadetex = 47500
nest_size.pdfjadetex = 500
param_size.pdfjadetex = 1500
save_size.pdfjadetex = 5000
stack_size.pdfjadetex = 15000
Hier zijn we verder gegaan en hebben regels toegevoegd voor jadetex en pdfjadetex, die we hieronder zullen instellen. Je kunt wat spelen met deze geheugeninstellingen zoals je dat wilt als je problemen ondervindt.

Na het instellen van hugelatex, zoals hierboven, werkt het wellicht niet totdat het programma texhash is aangeroepen:
root# texhash
texhash: Updating /usr/share/texmf/ls-R...
texhash: Updating /var/cache/fonts/ls-R...
texhash: Done.
root#


jadetex & pdfjadetex

Het instellen van jadetex en pdfjadetex is vergelijkbaar met het instellen van hugelatex.
cd /usr/local/openjade-1.3/dsssl
make -f Makefile.jadetex install
# make creates and installs the .fmt
# files to /usr/share/texmf/web2c

# Maak nu symlinks aan ...
cd /usr/share/texmf/bin
ln -s tex jadetex
ln -s pdftex pdfjadetex

# Start als laatste texhash op.
root# texhash
Deze Makefile gebruikt hugelatex, dus hugelatex moest reeds zijn ingesteld. Wanneer tex als hugelatex, jadetex, of pdfjadetex wordt uitgevoerd, krijgt het zijn programmanaam (context) van argv[0] in de omgeving. Dan scant het texmf.cnf, en gebruikt het alle context specifieke instellingen die het aantreft. De formaat (.fmt) bestanden in /usr/share/texmf/web2c worden ook gebaseerd op de context geladen.

De opdracht jadetex accepteert een tex bestand gegenereerd door openjade, en geeft als uitvoer een dvi. pdfjadetex accepteert een tex bestand gegenereerd door openjade en geeft als uitvoer een pdf bestand. Het programma dvips accepteert het dvi bestand en geeft als uitvoer een PostScript ps bestand welke je naar je printer kunt sturen of met ghostscript gs kunt bekijken.


DocBook SGML DTD

Pak de DocBook SGML DTD uit

De DocBook DTD bestaat gewoon uit een aantal sgml tekstbestanden, dus valt er niets te compileren. Pak ze gewoon ergens uit.
# DocBook DTD V4.1 in
# /usr/local/share/sgml/docbook/4.1

cd /usr/local/share
mkdir sgml; cd sgml
mkdir docbook; cd docbook
mkdir 4.1; cd 4.1
unzip -a ~/docbk41.zip
Als je doctools-1.2 uit de XFree86 distributie installeert, zullen er een aantal oudere versies van de DocBook DTD, zoals 2.4.1/ en 3.0/ in subdirectory's van docbook worden geïnstalleerd.

Er bestaan een aantal verschillen tussen de verschillende versies van de DocBook DTD. In de xxissues.txt bestanden worden die zaken gedocumenteerd. Tags die zijn toegevoegd, verwijderd en hernoemd tussen de versies.

Als je de DocBook DTD V3.1 nodig hebt, dan kun je het vanaf dezelfde plaats downloaden als waar V4.1 kan worden gedownload. V3.1 wordt veel gebruikt, dus het is een goed idee het op te halen en het te installeren in een 3.1/ subdirectory.


Pak de ISO8879 Entiteiten uit

Ga voor elk uitgepakte DocBook DTD naar die betreffende directory en pak het bestand iso8879-entities.tar.gz uit:
cd /usr/local/share/sgml/docbook/4.1
tar -xvzf ~/iso8879-entities.tar.gz
In elke DocBook directory zou een docbook.cat of catalog bestand of beiden voor moeten komen. Als beiden aanwezig zijn, dan zijn ze naar alle waarschijnlijkheid identiek. Als alleen docbook.cat aanwezig is, ga dan je gang en maak een symlink:
# Zonodig ...
cd /usr/local/share/sgml/docbook/4.1
ln -s docbook.cat catalog


DocBook DSSSL

De installatie van de DocBook DSSSL, welke voor alle versies van DocBook is, is slechts een kwestie van het ergens uitpakken.
cd /usr/local/share/sgml
mkdir dsssl; cd dsssl
unzip -a ~/db160.zip

# Als je de ldp.dsl stylesheet aanpassing downloadde, kopieer het dan naar
cd docbook
cp ~/ldp.dsl html
cp ~/ldp.dsl print
# Kopieer het naar beide directory's.
Dat is alles betreft het installeren van de DSSSL, behalve dan de setup van de variabele $SGML_CATALOG_PATH welke later wordt besproken. Vergeet niet de bestandsmodi en eigenaar/groep van deze uitgepakte bestanden recht te zetten, vaak zijn ze onjuist.


SGMLtools-Lite

Als je dat wilt, kun je de SGMLtools-Lite installeren, maar het is optioneel. De installatie ervan is de standaard:
cd /usr/src
tar -xvzf ~/sgmltools-lite-3.0.2.tar.gz
cd sgmltools-lite-3.0.2
./configure
make install
Hiermee wordt het sgmltools python script naar /usr/local/bin geïnstalleerd. Het maakt gebruik van python, dus als je het niet hebt, is dit package onbruikbaar.

Een aanpassing die moet worden uitgevoerd om het sgmltools script werkend te krijgen is het wijzigen ervan en het instellen van het pad naar openjade: vi `which sgmltools`. Raadpleeg de docs om er meer over te leren.


htmldoc

binary

Bijvoorkeur downloadde je een binaire distributie voor je platform van htmldoc. De installatie is eenvoudig: pak het gewoon uit en voer de setup uit. Lees de docs in het package voor meer info.


source

Als je de broncode downloadde, zul je ook de Fast Light Tool Kit nodig hebben, anders zal het niet linken:

http://www.fltk.org/

Installatie volgens de autoconf stijl. Start gewoon het script configure en make, make install. Als alles goed gaat, zal het worden geïnstalleerd in /usr/bin.


ldp_print

Het programma htmldoc heeft (of had) een paar tekortkomingen bij het genereren van uitvoer van html bestanden vanuit openjade. Opsommingsitems werden bijvoorbeeld niet juist weergegeven en geschaduwde gebieden waren niet altijd voorzien van schaduw.

Ter correctie van dit probleem is een perl script (ldp_print) beschikbaar vanaf LinuxDoc.org. Het script lpd_print verwerkt een nochunks html bestand van openjade en past er dan htmldoc op toe om een correct weergegeven pdf en ps te genereren.

Tip

Haal het op!

tar -xvzf ldp_print.tar.gz
cd ldp_print

# Kopieer de lib naar een lokatie waar perl het kan vinden.
cp fix_print_html.lib /usr/lib/perl5/site_perl

cp ldp_print /usr/local/bin
Bekijk het script voor het geval er regels instaan die je conform je systeem moet wijzigen. Misschien dat op een dag de programmeerfouten van htmldoc zijn opgelost en dat je dit script niet meer nodig zult hebben.


DocBook2X en SGMLS.pm (sgmlspl)

sgmlspl

Voor de spec files van DocBook2X van enig nut zijn, moet de SGMLS.pm module voor perl versie 5 zijn geïnstalleerd, in de veronderstelling dat perl 5 reeds is geïnstalleerd. De installatie van deze module is niet zo geautomatiseerd als de meeste installaties van perl modules. Het maakt gebruik van een Makefile dat moet worden gewijzigd voordat make wordt uitgevoerd.
cd /usr/src
tar -xvzf ~/SGMLSpm-1.03ii.tar.gz
cd SGMLSpm

# Wijzig Makfile
vi Makefile
# Stel in de user options van de Makefile
# alles correct in overeenkomstig je systeem.
# Voorbeeld:
#PERL = /usr/bin/perl
#BINDIR = /usr/local/bin
#PERL5DIR = /usr/lib/perl5/site_perl
#MODULEDIR = ${PERL5DIR}/SGMLS
#SPECDIR = ${PERL5DIR}
#HTMLDIR= /usr/local/apache/htdocs

make install
sgmlspl wordt gekopieerd naar /usr/local/bin.


docbook2X (docbook2man-spec.pl)

DocBook2X bevat geen programma voor het compileren of de installatie, alhoewel er een paar scripts zijn die je wellicht wilt bekijken. Je hoeft het dus alleen ergens uit te pakken.
cd /usr/local/share/sgml
tar -xvzf ~/docbook2X-0.6.0.tar.gz
cd docbook2X
In de directory met uitgepakte bestanden bevindt zich een docbook2man-spec.pl bestand en een patch file dat een aantal dingen corrigeert. Het toepassen van de patch is optioneel maar aan te bevelen.
patch docbook2man-spec.pl docbook2man-spec.pl.patch
Later, in Het gebruik van DocBook, zul je zien hoe sgmlspl en docbook2man-spec.pl kunnen worden toegepast om een man page vanuit een <refentry> DocBook document te genereren.


$SGML_CATALOG_FILES

De omgevingsvariabele $SGML_CATALOG_FILES wordt gebruikt door openjade (en andere SGML software) om DTD's en DSL (stylesheets) te lokaliseren. SGML software kan niet functioneren zonder deze bestanden, welke zijn uitgepakt in diverse directory's. Gegeven de setup tot dusverre wordt hier aangegeven hoe $SGML_CATALOG_FILES kan worden ingesteld in /etc/profile:
##########################################################################################
# SGML DocBook - openjade sgmltools-lite
JADE_HOME=/usr/local/openjade-1.3
SGML_SHARE=/usr/local/share/sgml

PATH=$PATH:$JADE_HOME/bin

# DSSSL stylesheets
#       Norman Walsh's Modular DocBook Stylesheets
SGML_CATALOG_FILES=$SGML_SHARE/dsssl/docbook/catalog
#       OpenJade stylesheets
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$JADE_HOME/dsssl/catalog
#       sgmltools-lite's stylesheets
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/stylesheets/sgmltools/sgmltools.cat

# DocBook DTD
#       Van OASIS-Open.org
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/3.1/catalog
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/4.1/catalog
#       Deze oude DTD's werden geïnstalleerd via doctools-1.2 van 
#       XFree86.org
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/2.4.1/catalog
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/docbook/3.0/catalog

# sgmltools-lite catalog bestanden voor LinuxDoc
SGML_CATALOG_FILES=$SGML_CATALOG_FILES:$SGML_SHARE/dtd/sgmltools/catalog

export JADE_HOME SGML_SHARE PATH SGML_CATALOG_FILES
##########################################################################################
Sla het bestand profile op, logout en log dan weer in om de wijzigingen te activeren.

Installatie compleet! In de volgende sectie, zullen we de installatie testen en een aantal DocBook testbestanden converteren.


Gebruiken van DocBook

Nu alles is geïnstalleerd, is de tijd aangebroken om het uit te gaan testen en te bekijken hoe openjade en de andere tools kunnen worden toegepast.

Figure 1. Voorbeeld DocBook SGML bestand - test.sgml

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">

<article lang="en">
<articleinfo>
<title>Dit is een test</title>

<author>
<firstname>John</firstname>
<surname>Doe</surname>
<othername role="mi">L</othername>
<affiliation>
<address>
<email>j.doe@jdoe dot com</email>
</address>
</affiliation>
</author>

<revhistory>
<revision>
<revnumber>v1.0</revnumber>
<date>30-12-2000</date>
<authorinitials>jld</authorinitials>
</revision>
</revhistory>

<abstract>
<para>
Dit is een DocBook testdocument.
</para>
</abstract>

</articleinfo>

<sect1 id="test1">
<title>Test 1</title>
<para>
Test sectie 1.
</para>
<sect2>
<title>Test 1.1</title>
<para>
Test sectie 1.1
</para>
</sect2>

<sect2>
<title>Test 1.2</title>
<para>
<screen>
-- Test sectie 1.2
openjade -t sgml -d $DSLFILE test.sgml
</screen>
</para>
</sect2>

</sect1>

<sect1 id="test2">
<title>Test 2</title>
<para>
Test sectie 2.
</para>

<sect2>
<title>Test 2.1</title>
<para>
Test sectie 2.1
</para>
</sect2>

<sect2>
<title>Test 2.2</title>
<para>
Test sectie 2.2
</para>
</sect2>

</sect1>
</article>
Zie voor een handleiding over DocBook en een referentie van DocBook elementen:

DocBook: The Definitive Guide. http://www.docbook.org/tdg/en/


HTML genereren

docbook.dsl

Figure 2. HTML-uitvoer genereren met behulp van docbook.dsl

bash$ ls -l
total 4
-rw-r--r--   1 reaster  users        1077 Dec 31 16:25 test.sgml
bash$ echo $SGML_SHARE
/usr/local/share/sgml
bash$ openjade -t sgml -d $SGML_SHARE/dsssl/docbook/html/docbook.dsl test.sgml
[snip - DTDDECL catalog entries are not supported, repeats]
bash$ ls -l
total 12
-rw-r--r--   1 reaster  users        1885 Dec 31 17:34 t1.htm
-rw-r--r--   1 reaster  users        1077 Dec 31 16:25 test.sgml
-rw-r--r--   1 reaster  users        1544 Dec 31 17:34 x27.htm
bash$
De waarschuwingen over DTDDECL kunnen worden genegeerd. Ze zijn wellicht wat ergerlijk, maar deze waarschuwingen zijn normaal wanneer openjade wordt gebruikt. Andere waarschuwingen en foutmeldingen zouden moeten worden onderzocht en deze geven vaak syntaxfouten aan die moeten worden gecorrigeerd.

Er worden twee htm bestanden gegenereerd, één voor elke <sect1>. De bestandsnamen zijn niet erg beschrijvend. Sectie één verschijnt op dezelfde pagina als de informatie over het artikel. Dit is het resultaat van het gebruik van de standaard stylesheet die wordt meegeleverd met de Modulaire DocBook Stylesheets, docbook.dsl.

Stylesheets kunnen worden aangepast om deze standaards te verbeteren. Als je het bestand ldp.dsl van het Linux Documentatie Project downloadde en het installeerde zoals weergegeven in sectie 3.3, dan heb je reeds een aangepaste stijl beschikbaar.


ldp.dsl

Figure 3. Genereren van HTML-uitvoer met ldp.dsl

bash$ openjade -t sgml -d $SGML_SHARE/dsssl/docbook/html/ldp.dsl#html test.sgml
bash$ ls -l
total 16
-rw-r--r--   1 reaster  users        2006 Dec 31 18:00 index.html
-rw-r--r--   1 reaster  users        1077 Dec 31 16:25 test.sgml
-rw-r--r--   1 reaster  users        1677 Dec 31 18:00 test1.html
-rw-r--r--   1 reaster  users        1598 Dec 31 18:00 test2.html
bash$

Met gebruik van ldp.dsl ziet de uitvoer er veel beter uit:

  • Er wordt een indexbestand aangemaakt met de informatie over het artikel.

  • Er wordt automatisch een inhoudsopgave gegenereerd.

  • Elke <sect1> komt in een eigen bestand.

  • Bestandsnamen worden afgeleid van ID-attributen van de <sect1> elementen.

  • De bestandsextensie wordt gewijzigd in html.

  • De <screen> elementen zijn geschaduwd.

Let op hoe het bestand ldp.dsl op de opdrachtregel wordt geschreven, "#html" is toegevoegd. ldp.dsl bevat twee <STYLE-SPECIFICATION> elementen, één met ID="html" en een ander met ID="print". Hiermee wordt de html stijl uit de ldp.dsl geselecteerd. De DocBook DSSSL bevat ondersteuning voor het converteren van DocBook bestanden naar html en print formaten. In sectie 3.3 kopieerde we ldp.dsl naar zowel de print als de html directory's. Bij het genereren van html uitvoer, zou de html style als hierboven moeten worden geselecteerd. Bij het genereren van andere type bestanden, zoals rtf en tex, vallen die onder de print stijl en dus zou de print stijl moeten worden geselecteerd uit ldp.dsl. Het alternatief is een commentaarteken te plaatsen voor de print of html stijl of deze te verwijderen uit de kopie van het bestand ldp.dsl in de respectieve directory. Als zich in een dsl bestand meer style-spec bevinden, en er geen wordt geselecteerd zoals in bovenstaand voorbeeld, dan zal de eerst aangetroffen stijl in het bestand worden geselecteerd. In het bestand ldp.dsl is de print style-spec het eerstvoorkomende in het bestand, dus wordt het standaard geselecteerd. Dus in bovenstaand voorbeeld zonder het toevoegen van "#html" bij het specificeren van ldp.dsl als de dsssl stylesheet, zou de "print" style-spec worden geselecteerd en gebruikt voor het genereren van de html uitvoer. Het zal wel werken, maar het is bedoeld voor wanneer de print/ldp.dsl wordt geselecteerd en de opmaak zal anders zijn.

Lees de documentatie voor de Modulaire DocBook Stylesheets om meer te leren over hoe de aanpassingen op de stylesheet bestanden kunnen worden gemaakt De aanpasssingen beslaan hoofdzakelijk het instellen van boolean optie parameters om de style features aan of uit te zetten. Een compleet nieuwe logicastijl kan worden geprogrammeerd in de DSSSL taal.

De openjade optie "-t output_type" specificeert het uitvoertype. De "-d dsssl_spec" optie is het pad naar de te gebruiken dsssl stylesheet. In bovenstaand voorbeeld, is het gespecificeerde uitvoertype sgml, wat bedoeld is voor SGML naar SGML transformaties. HTML, gedefineerd door de HTML Document Type Definition (DTD), is een SGML documenttype net als DocBook is, dus "sgml" is de correcte output_type optie. De andere twee uitvoertypes die gewoonlijk worden gebruikt zijn "rtf" en "tex". Het output_type tex zal later worden gebruikt om een tussenliggend formaat te creëren voor de aanmaak van pdf en ps formaten. De dsssl_spec moet een dsl bestand aangeven, geen directory.


Genereren van rtf en tex

bash$ ls -l
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
bash$ openjade -t rtf -d $SGML_SHARE/dsssl/docbook/print/ldp.dsl#print test.sgml
bash$ openjade -t tex -d $SGML_SHARE/dsssl/docbook/print/ldp.dsl#print test.sgml
bash$ ls -l
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex


Genereren van dvi en ps

Figure 4. jadetex uitvoeren om een Device Independent (dvi) bestand te genereren

-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$ jadetex test.tex
This is TeX, Version 3.14159 (Web2C 7.3.1)
(test.tex
JadeTeX 1999/06/29: 2.7
(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
(/usr/share/texmf/tex/jadetex/isoents.tex)
Elements will be labelled
Jade begin document sequence at 19
No file test.aux.
(/usr/share/texmf/tex/latex/cyrillic/ot2cmr.fd)
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/lucidabr/lmrhlcm.fd)
(/usr/share/texmf/tex/latex/hyperref/nameref.sty)
(/usr/share/texmf/tex/latex/psnfss/t1phv.fd)

LaTeX Warning: Reference `TEST1' on page 1 undefined on input line 238.


LaTeX Warning: Reference `20' on page 1 undefined on input line 262.


LaTeX Warning: Reference `23' on page 1 undefined on input line 285.


LaTeX Warning: Reference `TEST2' on page 1 undefined on input line 316.


LaTeX Warning: Reference `30' on page 1 undefined on input line 340.


LaTeX Warning: Reference `33' on page 1 undefined on input line 363.

[1.0.46] (/usr/share/texmf/tex/latex/psnfss/t1pcr.fd) [2.0.46] [3.0.46]
(test.aux)

LaTeX Warning: There were undefined references.

 )
Output written on test.dvi (3 pages, 34984 bytes).
Transcript written on test.log.
bash$ ls -l
total 80
-rw-r--r--   1 reaster  users         771 Dec 31 20:55 test.aux
-rw-r--r--   1 reaster  users       34984 Dec 31 20:55 test.dvi
-rw-r--r--   1 reaster  users        5072 Dec 31 20:55 test.log
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$ jadetex test.tex
This is TeX, Version 3.14159 (Web2C 7.3.1)
(test.tex
JadeTeX 1999/06/29: 2.7
(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
(/usr/share/texmf/tex/jadetex/isoents.tex)
Elements will be labelled
Jade begin document sequence at 19
(test.aux) (/usr/share/texmf/tex/latex/cyrillic/ot2cmr.fd)
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/lucidabr/lmrhlcm.fd)
(/usr/share/texmf/tex/latex/hyperref/nameref.sty)
(/usr/share/texmf/tex/latex/psnfss/t1phv.fd) [1.0.46]
(/usr/share/texmf/tex/latex/psnfss/t1pcr.fd) [2.0.46] [3.0.46] (test.aux) )
Output written on test.dvi (3 pages, 34148 bytes).
Transcript written on test.log.
You have new mail in /var/spool/mail/reaster
bash$ ls -l
total 80
-rw-r--r--   1 reaster  users         753 Dec 31 20:58 test.aux
-rw-r--r--   1 reaster  users       34148 Dec 31 20:58 test.dvi
-rw-r--r--   1 reaster  users        4433 Dec 31 20:58 test.log
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$

De eerste keer dat jadetex wordt uitgevoerd, worden waarschuwingen afgedrukt. Deze waarschuwingen kunnen worden genegeerd. Ze verschijnen niet meer als jadetex een tweede keer wordt uitgevoerd.

Figure 5. dvips uitvoeren om een PostScript (ps) bestand te genereren.

bash$ ls -l
total 80
-rw-r--r--   1 reaster  users         753 Dec 31 20:58 test.aux
-rw-r--r--   1 reaster  users       34148 Dec 31 20:58 test.dvi
-rw-r--r--   1 reaster  users        4433 Dec 31 20:58 test.log
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$ dvips test.dvi
This is dvips(k) 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com)
' TeX output 2000.12.31:2058' -> test.ps
<texc.pro><8r.enc><texps.pro><special.pro><color.pro>. [1] [2] [3]
bash$ ls -l
total 116
-rw-r--r--   1 reaster  users         753 Dec 31 20:58 test.aux
-rw-r--r--   1 reaster  users       34148 Dec 31 20:58 test.dvi
-rw-r--r--   1 reaster  users        4433 Dec 31 20:58 test.log
-rw-r--r--   1 reaster  users       34817 Dec 31 21:06 test.ps
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$

Figure 6. htmldoc uitvoeren om een PostScript (ps) bestand te genereren

bash$ ls -l
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
bash$ export DSL_HTML=$SGML_SHARE/dsssl/docbook/html/ldp.dsl\#html
bash$ openjade -t sgml -V nochunks -d $DSL_HTML test.sgml | htmldoc -f test-htmldoc.ps -
bash$ ls -l
-rw-r--r--   1 reaster  users        9050 Jan  1 00:44 test-htmldoc.ps
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
bash$
Als het ps bestand niet naar verwachting wordt weergegeven, dan kan dit te wijten zijn aan programmeerfouten in htmldoc. Kijk in het script ldp_print als je het wilt gebruiken om ps te genereren.


PDF genereren

Figure 7. pdfjadetex uitvoeren om een Portable Document Format (pdf) bestand te genereren.

bash$ ls -l
-rw-r--r--   1 reaster  users         753 Dec 31 20:58 test.aux
-rw-r--r--   1 reaster  users       34148 Dec 31 20:58 test.dvi
-rw-r--r--   1 reaster  users        4433 Dec 31 20:58 test.log
-rw-r--r--   1 reaster  users       34817 Dec 31 21:06 test.ps
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$ pdfjadetex test.tex
This is pdfTeX, Version 3.14159-13d (Web2C 7.3.1)
(test.tex[/usr/share/texmf/pdftex/config/pdftex.cfg]
JadeTeX 1999/06/29: 2.7
(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
(/usr/share/texmf/tex/jadetex/isoents.tex)
Elements will be labelled
Jade begin document sequence at 19
(test.aux) (/usr/share/texmf/tex/latex/cyrillic/ot2cmr.fd)
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/lucidabr/lmrhlcm.fd)
(/usr/share/texmf/tex/context/base/supp-pdf.tex
(/usr/share/texmf/tex/context/base/supp-mis.tex
loading : Context Support Macros / Missing
)
loading : Context Support Macros / PDF
) (/usr/share/texmf/tex/latex/hyperref/nameref.sty)
(/usr/share/texmf/tex/latex/psnfss/t1phv.fd) [1.0.46[/usr/share/texmf/dvips/con
fig/pdftex.map]] (/usr/share/texmf/tex/latex/psnfss/t1pcr.fd) [2.0.46] [3.0.46]
 (test.aux) )<8r.enc>
Output written on test.pdf (3 pages, 9912 bytes).
Transcript written on test.log.
bash$ ls -l
total 128
-rw-r--r--   1 reaster  users         753 Dec 31 21:13 test.aux
-rw-r--r--   1 reaster  users       34148 Dec 31 20:58 test.dvi
-rw-r--r--   1 reaster  users        5075 Dec 31 21:13 test.log
-rw-r--r--   1 reaster  users        9912 Dec 31 21:13 test.pdf
-rw-r--r--   1 reaster  users       34817 Dec 31 21:06 test.ps
-rw-r--r--   1 reaster  users        4584 Dec 31 20:51 test.rtf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
-rw-r--r--   1 reaster  users       18719 Dec 31 20:51 test.tex
bash$
bash$ pdfjadetex test.tex
[snip]
bash$ pdfjadetex test.tex
[snip]
pdfjadetex moet tot drie keer worden uitgevoerd om alle interne referenties op te lossen voor dingen zoals paginanummers voor in de TOC (Inhoudsopgave).

Figure 8. htmldoc uitvoeren om een Portable Document Format (pdf) bestand te genereren

bash$ ls -l
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
bash$ export DSL_HTML=$SGML_SHARE/dsssl/docbook/html/ldp.dsl\#html
bash$ openjade -t sgml -V nochunks -d $DSL_HTML test.sgml > test-htmldoc.htm
bash$ ldp_print test-htmldoc.htm
bash$ ls -l
-rw-r--r--   1 reaster  users        9050 Jan  1 01:17 test-htmldoc.pdf
-rw-r--r--   1 reaster  users        1143 Dec 31 18:18 test.sgml
bash$
Als dit zou zijn geactiveerd in het script ldp_print, zou dit ook een ps bestand gegeneren.


Gebruik van make

Het is saai om de opdrachten voor het genereren van de uitvoerbestanden te herhalen. De opdracht make werkt perfect om het proces te automatiseren.

Figure 9. Filename: Makefile - automates document generation.

# Genereert online en printversies van SGML bronbestand.

BASENAME=DocBook-Install

# SGML bronbestand.
SGML_FILE=$(BASENAME).sgml

# Stylesheets
DSL_PRINT=$(SGML_SHARE)/dsssl/docbook/print/ldp.dsl\#print
DSL_HTML=$(SGML_SHARE)/dsssl/docbook/html/ldp.dsl\#html

# Gegenereerde bestanden.
HTML_FILE=index.html
HTM_FILE=$(BASENAME).htm
TEX_FILE=$(BASENAME).tex
RTF_FILE=$(BASENAME).rtf
PDF_FILE=$(BASENAME).pdf
DVI_FILE=$(BASENAME).dvi
PS_FILE=$(BASENAME).ps


# Build rules.

html: $(HTML_FILE)

htm: $(HTM_FILE)

tex: $(TEX_FILE)

rtf: $(RTF_FILE)

pdf: $(PDF_FILE)

dvi: $(DVI_FILE)

ps: $(PS_FILE)

all: html htm tex rtf pdf dvi ps

clean:
rm -f $(BASENAME).{htm,log,aux,ps,pdf,tex,dvi,rtf,fot}
rm -f *.html

distclean: clean
rm -f $(BASENAME).tgz

package:
rm -f $(BASENAME).tgz
tar -C .. -czf /tmp/$(BASENAME).tgz $(BASENAME)
mv /tmp/$(BASENAME).tgz .

dist: clean package

distall: all package


# Compileerregels

$(HTML_FILE): $(SGML_FILE)
openjade -t sgml -d $(DSL_HTML) $(SGML_FILE)

$(HTM_FILE): $(SGML_FILE)
openjade -t sgml -V nochunks -d $(DSL_HTML) \
$(SGML_FILE) > $(HTM_FILE)

$(TEX_FILE): $(SGML_FILE)
openjade -t tex -d $(DSL_PRINT) $(SGML_FILE)

$(RTF_FILE): $(SGML_FILE)
openjade -t rtf -d $(DSL_PRINT) $(SGML_FILE)

# [pdf]jadetex is run 3 times to resolve references.
#$(PDF_FILE): $(TEX_FILE)
#pdfjadetex $(TEX_FILE)
#pdfjadetex $(TEX_FILE)
#pdfjadetex $(TEX_FILE)

# This *should* work, but htmldoc has bugs ...
#$(PDF_FILE): $(SGML_FILE)
#openjade -t sgml -V nochunks -d $(DSL_HTML) \
#$(SGML_FILE) | htmldoc -f $(PDF_FILE) -

# Have to use ldp_print to work around htmldoc bugs
# ldp_print can also do the ps file - see script
$(PDF_FILE): $(HTM_FILE)
ldp_print $(HTM_FILE)

$(DVI_FILE): $(TEX_FILE)
jadetex $(TEX_FILE)
jadetex $(TEX_FILE)
jadetex $(TEX_FILE)

$(PS_FILE): $(DVI_FILE)
dvips $(DVI_FILE)

#$(PS_FILE): $(SGML_FILE)
#openjade -t sgml -V nochunks -d $(DSL_HTML) \
#$(SGML_FILE) | htmldoc -f $(PS_FILE) -

Het gebruik gaat net als bij de meeste andere projecten:

Figure 10. make aanroepen om Makefile uit te voeren

-- generate html (default)
make
-- generate just pdf
make pdf
-- generate all files
make all
-- delete all generated files
make clean
-- create tgz distribution
-- with no generated files
make dist
-- create tgz distribution
-- containing all generated files
make distall

Let op de becommentarieerde compileregels voor pdf en ps die voorzien in alternatieve middelen voor het genereren van die bestanden.


Genereren van een man page

Tijdens de sectie over de installatie van alle packages, installeerden we de perl versie 5 module SGMLS.pm. Toen installeerden we Docbook2X wat voorziet in de spec.pl bestanden voor het transformeren van DocBook <refentry> documenten naar nroff (man page) formaat met sgmlspl.

Een voorbeeld van een DocBook <refentry> document, voor de opdracht foo wordt hieronder gegeven.

Figure 11. foo command man page, docbook <refentry> source (foo-ref.sgml)

<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<refentry>
<refentryinfo>
<date>2001-01-01</date>
</refentryinfo>
<refmeta>
<refentrytitle>
<application>foo</application>
</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>foo 1.0</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
<application>foo</application>
</refname>
<refpurpose>
Doet niets nuttigs.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2001-01-01</date>
</refsynopsisdivinfo>
<cmdsynopsis>
<command>foo</command>
<arg><option>-f </option><replaceable class="parameter">bar</replaceable></arg>
<arg><option>-d<replaceable class="parameter">n</replaceable></option></arg>
<arg rep="repeat"><replaceable class="parameter">file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<refsect1info>
<date>2001-01-01</date>
</refsect1info>
<title>DESCRIPTION</title>
<para>
<command>foo</command> doet niets nuttigs.
</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>-f <replaceable class="parameter">bar</replaceable></term>
<listitem>
<para>
Accepteert <filename>bar</filename> als zijn besturingsbestand
Als dit een echt programma was, zou er wellicht 
hier meer te zeggen zijn wat bar is en hoe het zal worden gebruikt.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-d<replaceable class="parameter">n</replaceable></term>
<listitem>
<para>
Doe iets, waar de integer
<replaceable class="parameter">n</replaceable>
aangeeft hoevaak.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">file...</replaceable></term>
<listitem>
<para>
Verwerkt de bestanden in de aangegeven volgorde, waarbij het
alle uitvoer naar stdout zendt.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>USAGE</title>
<para>
<command>foo</command> -f foo.conf -d2 foodata.foo
</para>
</refsect1>
<refsect1>
<title>CAVEATS</title>
<para>
Andere programma's met de naam <command>foo</command> kunnen bestaan in werkelijkheid wel iets doen!
</para>
</refsect1>
<refsect1>
<title>BUGS</title>
<para>
Geen. Programma doets niets.
</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>
<author>
<firstname>Foo</firstname>
<othername role="mi">E</othername>
<surname>Bar</surname>
<contrib>Oorspronkelijke auteur</contrib>
</author>
</para>
</refsect1>
</refentry>

Figure 12. Genereren van een man page met onsgmls, sgmlspl, en docbook2man-spec.pl

bash$ ls -l
-rw-r--r--   1 reaster  users        2434 Jan  3 03:51 foo-ref.sgml
bash$ onsgmls foo-ref.sgml | sgmlspl $SGML_SHARE/docbook2X/docbook2man-spec.pl
bash$ ls -l
-rw-r--r--   1 reaster  users        2434 Jan  3 03:51 foo-ref.sgml
-rw-r--r--   1 reaster  users        1129 Jan  3 04:03 foo.1
-rw-r--r--   1 reaster  users           0 Jan  3 04:03 manpage.links
-rw-r--r--   1 reaster  users           0 Jan  3 04:03 manpage.log
-rw-r--r--   1 reaster  users          15 Jan  3 04:03 manpage.refs
bash$ groff -mandoc -Tascii foo.1

FOO(1)                                                     FOO(1)


NAME
       foo - Doet niets nuttigs.

SYNOPSIS
       foo [ -f bar ]  [ -dn ]  [ file... ]

DESCRIPTION
       foo doet niets nuttigs.

OPTIONS
       -f bar Accepteert bar als zijn besturingsbestand. Als dit een
              echt programma was, dan zou er wellicht meer te zeggen zijn
              over wat bar is en hoe het zal worden gebruikt.

       -dn    Doe iets,  waar de integer n aangeeft hoevaak.

       file...
              Verwerkt de bestanden in de aangegeven volgorde, waarbij het
	      alle uitvoer naar stdout zendt.

USAGE
       foo -f foo.conf -d2 foodata.foo

CAVEATS
       Anders programma's  met de naam foo kunnen bestaan en in
       werkelijkheid wel iets doen!

BUGS
       Geen. Programma doet niets.

AUTHOR
       Foo E Bar (Oorspronkelijke auteur)

[snip - verscheidene extra witregels die man niet zou moeten tonen]
foo 1.0                     2001-01-01                          1
bash$ groff -mandoc -Tascii foo.1 | less
bash$ less foo.1

De man page, foo.1, wordt gegeneerd als een Sectie 1 pagina. De opdracht groff wordt gebruikt om de opgemaakte verschijning te bekijken.

Deze man hoort thuis in een man/man1 directory. De directory man/ moet zijn toegevoegd aan de omgevingsvariabele $MANPATH. De standaardlokatie is /usr/local/man/man1. De standaardsecties in het systeem met man pages bestaan uit de secties 1 tot en met 9. Elk is bedoeld voor het bijhouden van specifieke catagoriën documentatie.

Table 1. Manual Pages Secties

SectieDoel
man1Gebruikersprogramma's
man2Systeemaanroepen
man3Library functies en subroutines
man4Devices
man5Bestandsformaten
man6Games
man7Diversen
man8Systeembeheer
man9Kernel interne variabelen en functies

Tip

Het bronbestand voor een man page, zoals foo-ref.sgml, kan net als elk ander DocBook bestand worden omgezet in alle andere formaten. Een manpage kan met dezelfde eerder besproken opdrachten worden omgezet in html, rtf, tex, pdf, dvi, en ps formaten. Dit kan je echt heel veel conversiewerk besparen!

Veel plezier !


A. Legal

Copyright en licenties

Copyright (c) 2001, 2002 Robert B. Easter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".


Disclaimer

Er wordt geen aansprakelijkheid aanvaard voor de inhoud van dit document. Gebruik de concepten, voorbeelden en andere inhoud op eigen risico.

Alle copyrights vallen in handen van hun respectieve eigenaren, tenzij specifiek anders vermeld. Gebruik van een term in dit document moet niet wordt aangemerkt als van invloed zijnde op de geldigheid van enig handels- of servicemerk.

Het benoemen van bepaalde producten of merken moet niet worden gezien als onderkenning daarvan.


B. GNU Free Documentation License

Version 1.1, March 2000

Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.


0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.


1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".

A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.

The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.

A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.


2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies.


3. COPYING IN QUANTITY

If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.


4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

  1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.

  2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).

  3. State on the Title page the name of the publisher of the Modified Version, as the publisher.

  4. Preserve all the copyright notices of the Document.

  5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.

  6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.

  7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.

  8. Include an unaltered copy of this License.

  9. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.

  10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.

  11. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.

  12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.

  13. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.

  14. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.


5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements."


6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.


7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate.


8. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail.


9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.


10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.


How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. A copy of the license is included in the section entitled "GNU Free Documentation License".

If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being LIST"; likewise for Back-Cover Texts.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.