A Gentle Guide to Docbook brief introduction Docbook
How to use the portable document Creator How to use this portable document creation program
Author: Joe "Zonker" Brockmeier (jbrockmeier@earthlink.net) freelance writer Release Date: 1 September 2000 Translator: taowen (taowen.bitapf.org) translation Date: February 4, 2004 Source: IBM DeveloperWorks
Contents: What is DocBook Why use DocBook Creating a document with DocBook Including images Including code Including lists A basic template Converting to other file formats Exporting to HTML Exporting to plain text Exporting to PostScript Where to go next Resources About the author??
Directory: What is DocBook? Why use docbook? Creating a document with DOCBook Contains an image Containing code contains a list of simple templates to convert to other file formats Export to HTML Export to Pure Text Export to PostScript Next What Resources About Authors
This article explains what DocBook is and how to create a simple document using DocBook. Joe Brockmeier walks you through creating a document and using SGML-tools Lite to parse the document and make HTML, PostScript, plain-text, and PDF versions of the document . HE Also include, ignal references on docbook and tips lite and other docbook tools. This article explains what is docbook and create a simple document using Docbook. Joe BROCKMEIER takes you a document and uses SGML-Tools Lite to resolve the document creation document HTML, PostScript, plain text, and PDF versions. He also includes more reference materials for Docbook and how to find SGML-Tools Lite and other Docbook tools.
If you've ever thought about writing documentation for an open source project, or if you've browsed the Linux Documentation Project or any page dedicated to documentation for Linux or other open source projects, you've probably heard of DocBook. But you may NOT BE QUITE SURE What IT IS. If you have heard how to write documents to open source projects, or you have already browsed the Linux documentation item or any page of the document that serves Linux or other open projects, you may have heard of Docbook. But you may not be confident that it is.
What is docbook? What is docbook? DocBook is a markup language defined by an SGML or XML document type definition (DTD). Basically, DocBook is a set of tags that describe a document's structure. DocBook tags are similar to HTML tags, so if you've done any HTML, then DocBook will not be entirely foreign to you. DocBook is a bit more involved than HTML, but it is also much more useful than plain HTML because it facilitates the rendering of multiple formats from a single document. This article will describe how to create a SIMPLE ARTICLE (Document) in docbook and how to render severage document. docbook is a tag language defined by the SGML or XML Document Type Definition (DTD). Simply put, DocBook is a set of description documents labels. Docbook tags are similar to the HTML tag, so if you write HTML, then Docbook will not be too strange to you. Docbook is more complicated than HTML, but it is also much more useful than ordinary HTML because it provides a single document to a variety of formats. This article describes how to create a simple article (document) with Docbook and how to use SGML-Tools Lite to render several file formats from this document.
DocBook has been around, in one form or another, since 1991. Originally DocBook was created to help exchange UNIX documentation. Since then DocBook gone through four major versions and now is under the guidance of the Organization for the Advancement of Structured Information Standards, better KNOWN As Oasis (see resources). Docbook has been in various forms for a long time, starting from 1991. At first, Docbook was created to help swap UNIX documents. Since then, Docbook has experienced four major versions, and now is the formatting information standard progress organization, and more common is Oasis (see Resources), under the leadership.
Occasionally, the term DocBook is also used as a catchall term to describe the markup language and the tools used to convert DocBook documents into other formats. Technically, DocBook is only the DTD, but without SGML-tools Lite and other conversion tools DocBook isn ' T QUITE As Useful. Incidentally, the word Docbook is also used as a word for one million gold oil to describe the tag language and to convert the DocBook document to other formats. Technically, DocBook is just DTD, but there is no SGML-Tools Lite and other conversion tools, Docbook will not be too useful. Why use docbook? Why use docbook?
The main selling point for DocBook is its portability. A document written in DocBook markup can be converted into HTML, PostScript, PDF, RTF, DVI, and plain ASCII text easily and quickly without any expensive tools. In fact, DocBook and all of the tools used to work with DocBook are freely available under open source licenses. DocBook documents are plain text, and can be edited with any text editor or word processor that can save documents as plain ASCII text. Note that if you use a word processor, take extra care to save DocBook documents as plain text;. otherwise they will not parse correctly If you'll want to use your documentation in more than one format, like print and online, you'll find DocBook is a great solution DocBook major. The selling point is portability. A document written in a Docbook markup can quickly and easily convert to HTML, PostScript, PDF, RTF, DVI, and ASCII plain text, and do not require any expensive tools. In fact, Docbook and all the tools used by all supporting DocBook are freely used in open source authorization. The DocBook document is plain text and can be edited by any text editor or a word processor capable of storeing a document as an ASCII text. Note that if you are using the word processor, you should pay attention to put the docbook as plain text; otherwise they can't be parsed correctly. If you don't want to use your documents in a format, like printing version and web version, you may find that docbook is an excellent choice.
Another advantage of DocBook is that it frees the author from worrying about the formatting and layout of a document. DocBook is only concerned with the structure of a document. For instance, an author simply uses the DocBook markup to indicate text that should be emphasized with the
Creating a document with DocBook is easy. We'll focus on creating a document using the SGML DTD. With the exception of the document declaration, everything in this article should apply to XML as well as the SGML DTD. Is not difficult to create a document with DocBook . We will concentrate on how to create a document using SGML DTD. In addition to documentation declaration, all content in this article can be used for XML and SGML DTDs.
To begin, Fire Up your favorite. The first line of a docbook document is the document declaration. First, open your favorite text editor and create a new document. The first line of the Docbook document is the document statement.
Every DocBook document requires a document declaration to be considered valid. This lets SGML-tools Lite, or whatever tool you're using, know what version of the DTD you are using and the type of document that you are creating. All DocBook to become Valid requires a document statement. This makes SGML-Tools Lite or any other tool you are using, know the version of the DTD and the type of document you created.
Now we'll start adding a little meat to the document. We'll start with a title, author information, and a short paragraph. This brief example shows a few of the basic DocBook tags, or elements, in use. While DocBook elements may look similar to HTML tags, remember that DocBook parsers are much more demanding than your average Web browser. While you can get away with not declaring an HTML document, or even skipping some "required" tags, DocBook is not quite so forgiving. Be Careful to include All Required Elements and use the their proper order. Now we start to add some content to the document. From the title, author information and a small paragraph. This short example shows some labels for the basic DocBook, or elements. Docbook's elements may look similar to the HTML tag, but remember that docbook parsers are strict than your web browser. You may not declare the HTML document, even omitted some "must" tags, but DocBook will not be so wide. Note that all necessary elements and use them in a suitable order.
Most of the elements used here are self-explanatory. Some of the elements, such as the tag to a
tag, you cannot Skip from a
tag directly to the
tag, you can't cross
The next element is the
Some elements in DocBook can also include attributes that further describe the element. The
To include an image in your document, you can use any of several elements. The
To include an image in your document, you will use three elements: the
This code includes the fuzzy.eps image in your document when you render it using SGML-tools Lite or one of the other DocBook conversion tools. Note that eps is a good format for printing documents or converting to PDF, but you would want to use A JPEG, GIF, OR PNG File for Web Publication. The Docbook Rendering Tools Do Not Convert Image File Formats, So You'll NEED To Have Type Output You Want To Use. When you use SGML- Tools Lite or other Docbook Conversion Tool When you render it, these codes contain Fuzzy.eps images in your document. Note that the EPS is used for a good format that is converted to PDF due to documents or converted to PDF, but you may use JPEG, GIF, or PNG files to be published in the network. The DocBook rendering tool does not convert file format, so you need to keep them native formats for any type of output you want. INCLUDING CODE contains code
Often when writing documentation it is useful to quote source code within the document. The tag in HTML, however the
tag in HTML, however
Note that the above code uses the
One Thing That You'll Probably Want To Do As Well Is Make Lists - Either Bulleted Lists or Numbered Lists - Using The
The
A Basic Template A simple template
When I started learning DocBook I found it was easier to create a basic template rather than trying to remember all of the necessary elements off the top of my head. This is a basic article template, which may help you get started on your first DocBook documents . you should be able to simply cut and paste this from your browser into your favorite text editor and get started. you should check to be sure that the version of DocBook you are using is the same as the version in the declaration in the template. IF not, be sure to change it to the property. I found a simple template when I started learning Docbook, I am quite easy to try to remember all necessary elements in my brain. It is not so easy. This is a basic article template that will help you start writing your first Docbook document. You should be able to simply cut and paste it from you to your most common text editor and start. You should check that you want to use the version number of docbook, is the same as the version declared in the template. If not, make sure you change it to the right version.
Converting to Other File Formats Convert to Other Files
Often authors will use DocBook and never actually need to render the documents into other formats themselves. However, if you need to once you have a finished DocBook file, you can then convert that file into several other types of files using SGML-tools Lite. If you're using a Linux distribution, you may already have SGML-tools Lite or SGML-tools already installed. you may want to check and see if they're already installed and working, or if they are on your installation CDs. writing People often use docbook but never use themselves to render documents to other formats. However, if you need, as long as you have a completed docbook file, you can convert the file to several file formats with SGML-Tools Lite. If you are using Linux, you may have installed SGML-Tools Lite or SGML-Tools. You may want to check if you have already installed it, or they are on your installation CD. If you get errors when trying to parse your DocBook files, check the syntax of your document. Often something as simple as a forgotten "/" or misplaced element is the only problem. Get an error if you try to resolve your DocBoo file Check the syntax of your document. Regular problems are just simple or misunderstanded elements like forgetting "/".
If you do not have them already installed, and you want to be able to render documents yourself, you can download them from the SGML-tools Lite home page. To get the latest version, go to the SGML-tools Lite home page hosted On SourceForge (See Resources) and Download Either the Source OR RPM AND FOLLOW The Instructions on The SGML-Tools Lite Home Page To Install Them. If you haven't installed them, you want you to render documents, you can from SGML -Tools Lite's home page downloads them. To get the latest version, go to the homepage of SGML-Tools Lite (see Resources) (see Resources) and download the either source code or RPM, follow the instructions on the SGML-Tools Lite home page to install them.
Exporting to HTML exported to HTML
To Export a docbook document named filename.sgml to html, Simply Type The FOLLOWING: To export the name for FileName.sgml to HTML, simply use:
sgmltools -b html filename.sgmlIf the document has no major errors, SGML-tools Lite will produce a "filename" directory with the resulting HTML files inside. If the document is no major errors, SGML-tools Lite will produce results within a HTML The "filename" directory of the file.
Exporting to Plain Text Export to Pure Text
Docbook Also Supports Plain-Text Documents. To Render A Plain Ascii-text Document, Use The Following Command: Docbook also supports plain text documentation. To render a pure ASCII text document, use the command:
SGMLTOOLS -B TXT FileName.sgml
This Is The Same As the Command Used to Convert To HTML, Except We've Replace "HTML" with "txt". The -b argument txt "as the" backend ". Currently there several backends That Are Available: HTML, TXT, RTF, PS, AND DVI. This is the same as commands used to convert to HTML, except that we replace "HTML" to "TXT". The -b parameter tells SGML-Tools to use "TXT" as "backend". There are several Backend available: HTML, TXT, RTF, PS, and DVI.
Exporting to PostScript Export to PostScript
. DocBook is capable of producing output suitable for commercial printing through PostScript When converting to PostScript the command syntax is the same as for text or HTML: DocBook able for commercial printing through PostScript. Convert the syntax of the command of PostScript and the same as the text and HTML:
SGMLTOOLS -B PS filename.sgml
However, it is worth noting that if you are including images in the document, you will need to have them saved in EPS format to have them included in the PostScript document. SGML-tools Lite will not covert GIF or JPEG to PostScript for inclusion in However, if you contain this worthless of the image in the document, you will need to save them as the EPS format to enable them in the PostScript document. SGML-Tools Lite does not convert GIF or JPEG to PostScript for inclusion in the final document.
What is the next step in Where to Go Next?
This has just been a brief overview of using DocBook. It is by no means an exhaustive look at all of the elements or potential that DocBook has. Hopefully, however, this article will suffice to get you started learning more about DocBook. After following along with this article you should be able to create basic DocBook documents and use SGML-tools Lite to produce usable output from DocBook files. for more information on DocBook, you can consult the online documentation at DocBook.org (see Resources). this is for Use the short overview of Docbook. It does not have observations for the potential of elements and docbook. However, I hope this article is enough to start more learning for DocBook. After reading this article, you should be able to create a basic DocBook document and use SGML-Tools Lite to create a useful output from the DocBook file. To get more information about DocBook, you can query online documents located in docbook.org. (See Resources) If you would like to tinker a bit more with DocBook, a good place to start might be the Linux Documentation Project. Most of the documents in the LDP have a DocBook version available online that you could examine for more detailed usage of Docbook. If you want to have more observations for DocBook, a good place is Linux documentation project. Most documents in LDP have Docbook versions, you can learn more detailed use of DocBook.
Resources resources
Visit Docbook.org, The Main Docbook Site. Access Docbook.org, the primary site of Docbook.
The Linux Documentation Project Contains Many Documents Written in docbook. The LDP Authes The Started The Docbook.linux documentation contains many documents written in docbook. LDP authors have some tips on how to DocBook doors.
Download either the source or RPMs at SGML-tools Lite and follow the instructions to install them. This site has the tools you need to convert DocBook documents to HTML, PDF, PostScript, RTF, or plain text. Download SGML-tools Lite Source Code or RPM. This site has the tool you need to convert the DocBook document to HTML, PDF, PostScript, RTF, or plain text.
At The Oasis Docbook Pages, You'll Find The Docbook Technical Committee Home Page. You will find the homepage of the Docbook Technical Committee. For help getting started with any sgml dtd, see the w3c overview of sgml resources. To help SGML DTD, see W3C overview of SGML resources
For more details, see the general sgml / xml Applications, Oasis' Guide to SGML / XML Apps. To get more details, see General SGML / XML Applications, Oasis SGML / XML program guidance.
About the Author about the author
Joe "Zonker" Brockmeier is a contributing editor for Linux Magazine and has written Install, Configure and Customize Slackware Linux for Prima Publishing. Joe welcomes your questions, comments, or ideas for future articles on DocBook and can be reached at jbrockmeier@earthlink.net .