Transition docbook

xiaoxiao2021-03-06  39

Transition docbook

Version 0.1

Copyright © 2005 LT

This document is written in DocBook-XML-4.2 standard, using saxon6.5.3 to output HTML and FO, convert FO to PDF with FOP0.20.5.

I just started writing documentation with DocBook, I have a lot of things to do with the editorial tools you have learned. I have a lot of trouble, and I have a spending of the conversion of the documents. I finally solved the online information. I hope this article can give it. People who are being plagued for converting DocBook documents with help.

Before you start this article, you will give the online two articles: Limodou written by << Docbook learning >>, is the article I have learned DocBook; Cao Xiaoke Write << Add asia Fonts to Docbook-FOP, Hibernate Style >> Guide me to convert me Docbook documentation.

table of Contents

Overview

SAXON-FOP

1.1. Download Tool

1.2. Construction environment

2. xsltproc

Overview

Although there will be some discomfort when you start writing a DocBook document, but when you see a clear document, I believe it will fill all your dissatisfaction and complaints. After writing a few articles, I will get used to Docbook's grammar rules. In fact, the Elements commonly used by Docbook are not much.

Docbook documents have SGML, XML, two formats, conversion document styles There are also corresponding two formats DSSSL, XSL I use the XML document format that follows DocBook-XML-DTD rules. SGML is also a logo language, earlier than XML.

The DocBook documentation and conversion style can be resolved by the conversion tool to generate a specification, a variety of documents. Such as HTML form, PDF, RTF, CHM Javadoc, etc. The conversion tool used by myself XSLTProc, Saxon, and FOP, which will then describe the method of use.

Chapter 1 SAXON-FOP

1.1. Download Tool

Please pay attention to the comparison version number when downloading the conversion tool, and the author finds that some versions have bugs.

Docbook-DTD-4.2 Docbook-XSL-1.65.1 SAXON6.5.3 FOP0.20.5 PDF is inserted into the picture in Java Advanced Imaging Plug-Ins, Version 1.0 JAR package. Converting Chinese documents to use font files simsun.ttc and simhei.ttf, Chinese operating system can be found in% system% / fonts /

1.2. Construction environment

The establishment of the directory is as follows (references the Hibernate Chinese Manual Directory):

| --- Docbook

- suport

--- Lib (1)

- Docbook-DTD

- Docbook-XSL

--- zh-cn (2)

- images

- styles

- FOP

- modules

| --- Master.xml

| --- build.xml (3)

(1) Place the conversion tool assembly. (2) Place the images used by the document into the image, convert the style, and CSS Place the Styles folder, and place the required font files for the FOP in the FOP file. The DocBook source file to be converted is placed in the Modules folder, and the master.xml file is the starting file of the DocBook document. (3) Ant build file.

1, copy the download tool * .jar file to lib

2. When using FOP0.20.5 to generate a Chinese PDF file, please do the following (taken from Cao Xiaobu "DocBook TTF FOP writing Chinese")

FOP does not support Chinese fonts by default. The solution is to extract the FontMatrix file from the TTF font of Windows.

Java-cpd: /works/Hibernate2/doc/reference/support/lib/fop.jar; D: /Works/Hibernate2/doc/reference/support/lib/avalon-framework-cvs-20020806.jar Org.Apache.fop .FONTS.APPS.TTFREADER

C: /Windows/fonts/simhei.ttf simhei.xml

Java -cp d: /works/hibernate2/doc/reference/support/lib/fop.jar; D: / Works / Hibernate2 / Doc / Reference

/support/lib/avaalon-framework-cvs-20020806.jar org.apache.fop.fonts.apps.ttfreader -ttcname

"SIMSUN" C: /WINDOWS/FONTS/SIMSUN.TTTC SIMSUN.XML

Get two XML files: SIMSUN.XML, SUMHEI.XML; then registration in UserConfig.xml:

OK, the problem can be solved

Everyone in the generated PDF file is very long, no disconnection. In the blog of LimoDou, if you enforce the DocBook's ZH-CN, you can solve this problem in two false zh.xml files. Obviously this is a Bug.fop source code:

Org.apache.fop.Layout.Linearea.java 1407 lines:

String lang = hyphprops.language.tolowercase ();

IF ("zh" .equals (lang) || "ja" .Equals (lang) || "ko" .equals (lang)

|| "vi" .equals (lang))

Ret = true;

Obviously the problem is here. The author wants to write some Case that needs to be broken, but does not comply with the RFC 3066 specification.

change into:

IF (Lang.StartSwith ("EN" || Lang.StartSwith ("JA" || Lang.StartSwith ("Ko"

|| Lang.StartSwith ("VI")

Ret = true;

Rebate the FOP. Get it.

3. Establish an ANT build file.

Ant is a very easy to build tool, use and configuration is very simple, and Ant is no longer described here. This article refers to the build.xml document of the Hibernate Hanhua Working Group.

Example 1.1. Build.xml

Depends = "clean"

Description = "Compile Documentation for All Languages ​​and All Formats.">

->

Description = "Generates a Diff Report for All Translated Versions.">

Filepath = "$ {Basedir} / $ {lang} / fop" />

"- CREATE A PDF from the xsl / fo. ->

->

->

ClassName = "org.hibernate.docproc.revdiff.revdiffreporttask"

ClasspathRef = "lib.classpath">

Copy = "$ {basedir} / $ {lang} /master.xml"

Report = "$ {build.dir} / status _ $ {lang} .html" />

After the above configuration, enter the directory to run the Ant, the conversion document will place the build directory, verify the correctness of the XML before the conversion.

Chapter 2 XSLTPROC

Xsltproc has a version of C and Java languages. This article describes the C language version. Download XLStproc.

1. Establish the following directory

| --- Docbook

--- bin (1)

--- Lib (2)

- Source

- Docbook-DTD

- Docbook-XSL

(1) Place the * .exe file in XSLTPROC. (2) Place the file under all LIB in XSLTPROC under this folder.

2, set the bac and lib actual path to the system environment Path path.

The following is a conversion command commonly used by XSLTPROC

- Generate RTF files

XSLTProc conversion style file .xsl pending file .xml> output file .rtf

Example: xsltproc c: /share/style/docbook-xsl-1.65.1/html/docbook.xsl c: /share/demo1.xml> c: /share/demo3.rtf

- Generate an HTML file (pagination file)

XSLTProc -O Output Directory Conversion Style File. xi Roof File .xml

Example: xsltproc -o c: / share / src / c: /share/style/docbook-xsl-1.65.1/html/chunk.xsl c: /share/demo1.xml

- Generate an HTML file (single page file)

XSLTProc -O output file .html conversion style file .xsl pending files .xml

Example: xsltproc -o c: /share/src/demo11.html c: /share/style/docbook-xsl-1.65.1/html/docbook.xsl C: / Share

/Demo1.xml

- Generate htmlhelp files

XSLTProc -O Output Directory Conversion Style File. xi Roof File .xml

Example: xsltproc -o c: / share / src / c: /share/style/docbook-xsl-1.65.1/htmlhelp/htmlhelp.xsl c: /share/demo1.xml

- Generate a javahelp file

XSLTProc -O Output Directory Conversion Style File. xi Roof File .xml

Example: xsltproc -o c: / share / src / c: /share/style/docbook-xsl-1.65.1/javahelp/javahelp.xsl c: /share/demo1.xml

- Generate an XML file

Xsltproc -o output file .xml conversion style file .xsl to be converted file .xml

Example: xsltproc -o c: /share/src/demo1_xml.xml c: /share/style/docbook-xsl-1.65.1/xhtml/docbook.xsl C: / Share

/Demo1.xml

- Generate a FO file

Xsltproc xsltproc conversion style file .xsl to be converted file .xml> Output file .fo

Xsltproc C: /share/style/docbook-xsl-1.65.1/fo/fop.xsl c: /share/demo1.xml> c: /share/my.fo

转载请注明原文地址:https://www.9cbs.com/read-65263.html

New Post(0)