-
Notifications
You must be signed in to change notification settings - Fork 0
/
section.docbook.utils.xml
333 lines (315 loc) · 9.41 KB
/
section.docbook.utils.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?xml version="1.0" encoding="UTF-8"?>
<chapter id="docbook.tools">
<title>Docbook 环境安装</title>
<subtitle>Document Tools</subtitle>
<para>Docbook SGML,XML 转换程序</para>
<section id="xsltproc">
<title>xsltproc - XSLT command line processor</title>
<para>xsltproc --stringparam html.stylesheet docbook.css ../../docbook-xsl-1.73.2/xhtml/chunk.xsl ../book.xml</para>
<screen>
<![CDATA[
$ sudo apt-get install docbook-xsl
$ export DSSSL=/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/chunk.xsl
$ /usr/bin/xsltproc --stringparam html.stylesheet docbook.css ${DSSSL} ../book.xml
]]>
</screen>
</section>
<section id="docbook-ebnf">
<title>docbook-ebnf - EBNF module for the XML version of the DocBook DTD</title>
<para>docbook-ebnf - EBNF module for the XML version of the DocBook DTD</para>
<screen>
<![CDATA[
$ sudo apt-get install docbook-ebnf
]]>
</screen>
</section>
<section id="docbook-xsl-saxon">
<title>docbook-xsl-saxon</title>
<screen>
$ sudo apt-get install docbook-xsl-saxon
</screen>
<para>创建一个test.xml的测试文件</para>
<screen>
<![CDATA[
SRCS = test.xml
DESTDIR = .
all: html
html: $(SRCS:.xml=.noext.html) $(SRCS:.xml=.html)
%.png : %.png.uu
[ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
uudecode -o /dev/stdout < $< > ${DESTDIR}/$@
%.html : %.xml
[ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
java -cp "/usr/share/java/saxon.jar:/usr/share/java/xslthl.jar:/usr/share/java/docbook-xsl-saxon.jar" \
-Dhighlight.xslthl.config="/usr/share/xml/docbook/stylesheet/docbook-xsl/highlighting/xslthl-config.xml" \
com.icl.saxon.StyleSheet \
-u -o ${DESTDIR}/$@ $< db2html.xsl \
highlight.source=1
%.noext.html : %.xml
[ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
xsltproc --xinclude --nonet -o ${DESTDIR}/$@ \
--stringparam highlight.source 1 \
--stringparam xslthl.config /usr/share/xml/docbook/stylesheet/docbook-xsl/highlighting/xslthl-config.xml \
--param use.extensions 0 \
--stringparam paper.type A4 \
db2html.xsl $<
validate: check
check:
xmllint --xinclude --nonet --noout --postvalid $(SRCS)
clean:
rm -f ${DESTDIR}/*.html ${DESTDIR}/*.png
.PHONY: all check clean html validate
]]>
</screen>
<para>生成html</para>
<screen>
<![CDATA[
cp /usr/share/doc/docbook-xsl-saxon/examples/db2html.xsl 。
make html
]]>
</screen>
</section>
<section id="docbook.pdf">
<title>PDF</title>
<screen>
<![CDATA[
sudo apt-get install docbook-xml docbook-xsl xsltproc fop
]]>
</screen>
<para>安装字体</para>
<screen>
<![CDATA[
sudo mkdir /usr/share/fonts/microsoft
]]>
</screen>
<para>将 C:\Windows\Fonts 目录中的字体复制到 /usr/share/fonts/microsoft </para>
<screen>
<![CDATA[
$ java -cp /usr/share/java/fop.jar org.apache.fop.fonts.apps.TTFReader /usr/share/fonts/microsoft/simhei.ttf simhei.xml
$ java -cp /usr/share/java/fop.jar org.apache.fop.fonts.apps.TTFReader -ttcname "SimSun" /usr/share/fonts/microsoft/simsun.ttc simsun.xml
]]>
</screen>
<screen>
<![CDATA[
sudo vim /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/param.xsl
<xsl:param name="callout.unicode.font">simsun</xsl:param>
<xsl:param name="symbol.font.family">simsun</xsl:param>
<xsl:param name="callout.unicode.font">simsun</xsl:param>
]]>
</screen>
<!-- <xsl:param name="body.font.family"></xsl:param> <xsl:param name="title.font.family"></xsl:param> -->
<screen>
<![CDATA[
$ vim fop.conf
<?xml version="1.0"?>
<fop version="1.0">
<base>.</base>
<renderers>
<renderer mime="application/pdf">
<filterList>
<value>flate</value>
</filterList>
<fonts>
<font metrics-url="simhei.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simhei.ttf">
<font-triplet name="simhei" style="normal" weight="normal"/>
<font-triplet name="simhei" style="normal" weight="bold"/>
<font-triplet name="simhei" style="italic" weight="normal"/>
<font-triplet name="simhei" style="italic" weight="bold"/>
</font>
<font metrics-url="simsun.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simsun.ttc">
<font-triplet name="simsun" style="normal" weight="normal"/>
<font-triplet name="simsun" style="normal" weight="bold"/>
<font-triplet name="simsun" style="italic" weight="normal"/>
<font-triplet name="simsun" style="italic" weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
]]>
</screen>
<screen>
xsltproc -o helloworld.fo /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl helloworld.xml
fop -c fop.conf helloworld.fo -pdf helloworld.pdf
</screen>
</section>
<section id="chm">
<title>CHM</title>
<para>
下载
<ulink url="http://download.microsoft.com/download/0/a/9/0a939ef6-e31c-430f-a3df-dfae7960d564/htmlhelp.exe">HTML Help Wordshop</ulink>
工具,并安装
</para>
<screen>
copy “c:\Program Files\HTML Help Workshop\hhc.exe” d:\docbook\example
xsltproc –xinclude docbook_chm.xsl docbook.xml
hhc.exe htmlhelp.hhp
</screen>
<screen>
<![CDATA[
set PATH=C:\Program Files (x86)\HTML Help Workshop;%PATH%
hhc htmlhelp.hhp
]]>
</screen>
</section>
<section id="docbook2odf">
<title>docbook2odf - Convert docbook document to Oasis Open Document</title>
<screen>
<![CDATA[
sudo apt-get install docbook2odf
]]>
</screen>
<screen>
<![CDATA[
docbook2odf book.xml
]]>
</screen>
</section>
<section id="docbook.epub">
<title>EPUB</title>
<section id="epub.create">
<title>创建.epub文件</title>
<screen>
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<book>
<bookinfo>
<title>My EPUB book</title>
<author><firstname>Liza</firstname>
<surname>Daly</surname></author>
<volumenum>1234</volumenum>
</bookinfo>
<preface id="preface">
<title>Title page</title>
<figure id="cover-image">
<title>Our EPUB cover image icon</title>
<graphic fileref="cover.png"/>
</figure>
</preface>
<chapter id="chapter1">
<title>This is a pretty simple DocBook example</title>
<para>
Not much to see here.
</para>
</chapter>
<chapter id="end-notes">
<title>End notes</title>
<para>
This space intentionally left blank.
</para>
</chapter>
</book>
]]>
</screen>
<screen>
$ xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl docbook.xml
$ echo "application/epub+zip" > mimetype
$ zip -0Xq my-book.epub mimetype
$ zip -Xr9D my-book.epub *
</screen>
</section>
<section id="epub.reader">
<title>Reader</title>
<para>http://calibre-ebook.com/</para>
</section>
</section>
<section id="mac">
<title>Apple Mac</title>
<para>安装 dtd 文件</para>
<screen>
<![CDATA[
neo@MacBook-Pro ~ % brew install docbook
]]>
</screen>
<para>安装目录 /usr/local/Cellar/docbook/5.0/docbook/xml/5.0</para>
<para>安装 xsl 文件</para>
<screen>
<![CDATA[
neo@MacBook-Pro ~ % brew install docbook-xsl
]]>
</screen>
<para>安装目录/usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl/</para>
<screen>
<![CDATA[
neo@MacBook-Pro /tmp/doc % cat sample.xml
<?xml version="1.0" encoding="utf-8"?>
<book>
<bookinfo>
<title>My EPUB book</title>
<author><firstname>Liza</firstname>
<surname>Daly</surname></author>
<volumenum>1234</volumenum>
</bookinfo>
<preface id="preface">
<title>Title page</title>
<figure id="cover-image">
<title>Our EPUB cover image icon</title>
<graphic fileref="cover.png"/>
</figure>
</preface>
<chapter id="chapter1">
<title>This is a pretty simple DocBook example</title>
<para>
Not much to see here.
</para>
</chapter>
<chapter id="end-notes">
<title>End notes</title>
<para>
This space intentionally left blank.
</para>
</chapter>
</book>
]]>
</screen>
<screen>
<![CDATA[
neo@MacBook-Pro /tmp/doc % xsltproc /usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl/html/chunk.xsl sample.xml
Writing pr01.html for preface(preface)
Writing ch01.html for chapter(chapter1)
Writing ch02.html for chapter(end-notes)
Writing index.html for book
neo@MacBook-Pro /tmp/doc % ll
total 40
-rw-r--r-- 1 neo wheel 1.6K Sep 28 16:51 ch01.html
-rw-r--r-- 1 neo wheel 1.5K Sep 28 16:51 ch02.html
-rw-r--r-- 1 neo wheel 1.8K Sep 28 16:51 index.html
-rw-r--r-- 1 neo wheel 1.8K Sep 28 16:51 pr01.html
-rw-r--r-- 1 neo wheel 710B Sep 28 16:51 sample.xml
]]>
</screen>
</section>
§ion.docbook.website.xml;
<section id="docbook-xml">
<title>XML 工具</title>
<section>
<title>rxp - A validating XML parser</title>
<para></para>
<para>rxp -s file.xml</para>
<para>To validate file.xml, use the command:</para>
<para>$ rxp -s -V file.xml</para>
</section>
<section id="xmllint">
<title>XML 校验</title>
<screen>
<![CDATA[
$ xmllint book.xml
]]>
</screen>
</section>
</section>
<section id="docbook-utils">
<title>SGML 环境</title>
<screen>
<![CDATA[
sudo apt-get install docbook-utils
]]>
</screen>
<para>CentOS</para>
<screen>
<![CDATA[
# yum install docbook*
]]>
</screen>
</section>
</chapter>