SGML/XML 标记语言基础
SGML 的特征
文档结构
如何将文章分解成几块
(利用外部实体)
(利用外部实体)
Catalog 文件
The catalog file format was defined in 1994 by SGML Open (now OASIS). The formal specification is contained in OASIS Technical Resolution 9401:1997.
SGML 格式的 Catalog 文件
语法
对不同文档设置不同 SGMLDecl
如: 在一个 catalog 文件中既定义 DTD 的
声明文件,又定义XML的声明文件
声明文件,又定义XML的声明文件
SGMLDECL "dtd/docbook-4.5/docbook.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V4.5CR1//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V4.2//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V3.1//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V4.5CR1//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V4.2//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
DTDDECL "-//OASIS//DTD DocBook XML V3.1//EN" "dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl"
示例
-- Comments are delimited by pairs of double-hyphens,
as in SGML and XML comments. --
OVERRIDE YES
SGMLDECL "n:/share/sgml/docbook/3.1/docbook.dcl"
DOCTYPE BOOK n:/share/sgml/docbook/3.1/docbook.dtd
PUBLIC "-//OASIS//DTD DocBook V3.1//EN"
n:/share/sgml/docbook/3.1/docbook.dtd
SYSTEM "http://nwalsh.com/docbook/xml/1.3/db3xml.dtd"
n:/share/sgml/Norman_Walsh/db3xml/db3xml.dtd
as in SGML and XML comments. --
OVERRIDE YES
SGMLDECL "n:/share/sgml/docbook/3.1/docbook.dcl"
DOCTYPE BOOK n:/share/sgml/docbook/3.1/docbook.dtd
PUBLIC "-//OASIS//DTD DocBook V3.1//EN"
n:/share/sgml/docbook/3.1/docbook.dtd
SYSTEM "http://nwalsh.com/docbook/xml/1.3/db3xml.dtd"
n:/share/sgml/Norman_Walsh/db3xml/db3xml.dtd
XML格式的 Catalog 文件
语法
public/system 定位 DTD 位置
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<group prefer="public" xml:base="file:///usr/share/xml/" >
<public
publicId="-//OASIS//DTD DocBook XML V4.4//EN"
uri="docbook44/docbookx.dtd"/>
<system
systemId="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
uri="docbook44/docbookx.dtd"/>
<system
systemId="docbook4.4.dtd"
uri="docbook44/docbookx.dtd"/>
</group>
</catalog>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<group prefer="public" xml:base="file:///usr/share/xml/" >
<public
publicId="-//OASIS//DTD DocBook XML V4.4//EN"
uri="docbook44/docbookx.dtd"/>
<system
systemId="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
uri="docbook44/docbookx.dtd"/>
<system
systemId="docbook4.4.dtd"
uri="docbook44/docbookx.dtd"/>
</group>
</catalog>
uri 定位 XSL 样式表位置
(本地到本地)
(本地到本地)
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri
name="docbook.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/docbook.xsl"/>
</catalog>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri
name="docbook.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/docbook.xsl"/>
</catalog>
uri 将 web 地址对应本地文件
(URL 到本地)
(URL 到本地)
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system
systemId="http://www.oasis-open.org/docbook/xml/4.4/"
uri="file:///usr/share/xml/docbook44/" />
<uri
name="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/docbook.xsl" />
<uri
name="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/chunk.xsl" />
</catalog>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<system
systemId="http://www.oasis-open.org/docbook/xml/4.4/"
uri="file:///usr/share/xml/docbook44/" />
<uri
name="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/docbook.xsl" />
<uri
name="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"
uri="file:///usr/share/xml/docbook-xsl-1.68.1/html/chunk.xsl" />
</catalog>
rewriteSystem 建立重写规则,
简化、合并 URI 项
简化、合并 URI 项
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="file:///usr/share/xml/docbook44/" />
<rewriteURI
uriStartString="http://docbook.sourceforge.net/release/xsl/current/"
rewritePrefix="file:///usr/share/xml/docbook-xsl-1.68.1/" />
</catalog>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="file:///usr/share/xml/docbook44/" />
<rewriteURI
uriStartString="http://docbook.sourceforge.net/release/xsl/current/"
rewritePrefix="file:///usr/share/xml/docbook-xsl-1.68.1/" />
</catalog>
SGML 时代的 DocBook
OpenSP
编译 OpenSP 之前
OpenSP 补丁
isSgmlChar
文件: include/Syntax.h
diff -r -u OpenSP-1.5.1/include/Syntax.h OpenSP-1.5.1-new/include/Syntax.h
--- OpenSP-1.5.1/include/Syntax.h 2005-12-18 10:38:50.890625000 +0800
+++ OpenSP-1.5.1-new/include/Syntax.h 2005-12-18 10:44:20.703125000 +0800
@@ -389,7 +389,7 @@
inline Boolean Syntax::isSgmlChar(Xchar c) const
{
- return c >= 0 && set_[sgmlChar].contains(Char(c));
+ return c >= 256 || c >= 0 && set_[sgmlChar].contains(Char(c));
}
inline const StringC &Syntax::reservedName(ReservedName i) const
diff -r -u OpenSP-1.5.1/include/Syntax.h OpenSP-1.5.1-new/include/Syntax.h
--- OpenSP-1.5.1/include/Syntax.h 2005-12-18 10:38:50.890625000 +0800
+++ OpenSP-1.5.1-new/include/Syntax.h 2005-12-18 10:44:20.703125000 +0800
@@ -389,7 +389,7 @@
inline Boolean Syntax::isSgmlChar(Xchar c) const
{
- return c >= 0 && set_[sgmlChar].contains(Char(c));
+ return c >= 256 || c >= 0 && set_[sgmlChar].contains(Char(c));
}
inline const StringC &Syntax::reservedName(ReservedName i) const
允许中文注释
文件: lib/parseCommon.cxx
diff -r -u OpenSP-1.5.1/lib/parseCommon.cxx OpenSP-1.5.1-new/lib/parseCommon.cxx
--- OpenSP-1.5.1/lib/parseCommon.cxx 1999-11-04 16:36:13.000000000 +0800
+++ OpenSP-1.5.1-new/lib/parseCommon.cxx 2005-12-18 10:46:41.781250000 +0800
@@ -541,14 +541,12 @@
Token token;
while ((token = getToken(mode)) != tokenCom)
switch (token) {
- case tokenUnrecognized:
- if (!reportNonSgmlCharacter())
- message(ParserMessages::sdCommentSignificant,
- StringMessageArg(currentToken()));
- break;
case tokenEe:
message(ParserMessages::commentEntityEnd, startLoc);
return 0;
+ case tokenUnrecognized:
+ if (reportNonSgmlCharacter())
+ break;
default:
if (markup)
markup->addCommentChar(currentChar());
diff -r -u OpenSP-1.5.1/lib/parseCommon.cxx OpenSP-1.5.1-new/lib/parseCommon.cxx
--- OpenSP-1.5.1/lib/parseCommon.cxx 1999-11-04 16:36:13.000000000 +0800
+++ OpenSP-1.5.1-new/lib/parseCommon.cxx 2005-12-18 10:46:41.781250000 +0800
@@ -541,14 +541,12 @@
Token token;
while ((token = getToken(mode)) != tokenCom)
switch (token) {
- case tokenUnrecognized:
- if (!reportNonSgmlCharacter())
- message(ParserMessages::sdCommentSignificant,
- StringMessageArg(currentToken()));
- break;
case tokenEe:
message(ParserMessages::commentEntityEnd, startLoc);
return 0;
+ case tokenUnrecognized:
+ if (reportNonSgmlCharacter())
+ break;
default:
if (markup)
markup->addCommentChar(currentChar());
catalog
SGMLDECL "/home/JiangXin/work/docbook/dtd/4.5/docbook.dcl"
CATALOG "/home/JiangXin/work/docbook/dtd/4.5/docbook.cat"
DOCTYPE book /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
CATALOG "/home/JiangXin/work/docbook/dtd/4.5/docbook.cat"
DOCTYPE book /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
应用
准备
创建一个 catalog 文件
catalog 文件
DOCTYPE book /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
示例
-- ...................................................................... --
-- "export SGML_CATALOG_FILES=/PATH/catalog" --
OVERRIDE YES
SGMLDECL "/home/JiangXin/work/docbook/dtd/4.5/docbook.dcl"
CATALOG "/home/JiangXin/work/docbook/dtd/4.5/docbook.cat"
CATALOG "/home/JiangXin/work/docbook/style/dsssl-1.79/catalog"
-- CATALOG "dtd/openjade/catalog" --
-- CATALOG "/home/JiangXin/work/docbook/dtd/entities/catalog.sgml" --
DOCTYPE book /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
-- "export SGML_CATALOG_FILES=/PATH/catalog" --
OVERRIDE YES
SGMLDECL "/home/JiangXin/work/docbook/dtd/4.5/docbook.dcl"
CATALOG "/home/JiangXin/work/docbook/dtd/4.5/docbook.cat"
CATALOG "/home/JiangXin/work/docbook/style/dsssl-1.79/catalog"
-- CATALOG "dtd/openjade/catalog" --
-- CATALOG "/home/JiangXin/work/docbook/dtd/entities/catalog.sgml" --
DOCTYPE book /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE article /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
DOCTYPE chapter /home/JiangXin/work/docbook/dtd/4.5/docbook.dtd
docbook.dcl 补丁
- LCNMCHAR ".-_"
- UCNMCHAR ".-_"
+ LCNMCHAR ".-_:"
+ UCNMCHAR ".-_:"
- UCNMCHAR ".-_"
+ LCNMCHAR ".-_:"
+ UCNMCHAR ".-_:"
否则:
onsgmls:/home/JiangXin/work/docbook/dtd/4.5/htmltblx.mod:102:9:E: character ":"
invalid: only "CDATA", "ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", "NAME", "N
AMES", "NMTOKEN", "NMTOKENS", "NOTATION", "NUMBER", "NUMBERS", "NUTOKEN", "NUTOK
ENS" and parameter separators allowed
onsgmls:/home/JiangXin/work/docbook/dtd/4.5/htmltblx.mod:110:9:E: character ":"
invalid: only "CDATA", "ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", "NAME", "N
AMES", "NMTOKEN", "NMTOKENS", "NOTATION", "NUMBER", "NUMBERS", "NUTOKEN", "NUTOK
ENS" and parameter separators allowed
onsgmls:/home/JiangXin/work/docbook/dtd/4.5/htmltblx.mod:102:9:E: character ":"
invalid: only "CDATA", "ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", "NAME", "N
AMES", "NMTOKEN", "NMTOKENS", "NOTATION", "NUMBER", "NUMBERS", "NUTOKEN", "NUTOK
ENS" and parameter separators allowed
onsgmls:/home/JiangXin/work/docbook/dtd/4.5/htmltblx.mod:110:9:E: character ":"
invalid: only "CDATA", "ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", "NAME", "N
AMES", "NMTOKEN", "NMTOKENS", "NOTATION", "NUMBER", "NUMBERS", "NUTOKEN", "NUTOK
ENS" and parameter separators allowed
OpenJade
编译 OpenJade
测试(参见 dsssl-doc 的例子)
测试 openjade:
可能出现的错误
openjade:jtest.dsl:1:72:W: cannot generate system identifier for public text "-//James Clark//DTD DSSSL Style Sheet//EN"
openjade:jtest.dsl:1:72:E: reference to entity "STYLE-SHEET" for which no system identifier could be generated
openjade:jtest.dsl:1:0: entity was defined here
openjade:E: specification document does not have the DSSSL architecture as a base architecture
openjade:jtest.dsl:1:72:E: reference to entity "STYLE-SHEET" for which no system identifier could be generated
openjade:jtest.dsl:1:0: entity was defined here
openjade:E: specification document does not have the DSSSL architecture as a base architecture
如何指定 DSSSL 样式表
一个DSSSL样式表文件可能包含
多个样式,如何指定?
多个样式,如何指定?
两种方式定义的多样式DSSSL文件
仅通过参数进行实体控制,
只包含一个 style-specification
只包含一个 style-specification
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
]]>
]>
<style-sheet>
<style-specification use="docbook">
<style-specification-body>
;; common customization can go here
<![%print;[
;; customize the print stylesheet here
]]>
<![%html;[
;; customize the html stylesheet here
]]>
</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
]]>
]>
<style-sheet>
<style-specification use="docbook">
<style-specification-body>
;; common customization can go here
<![%print;[
;; customize the print stylesheet here
]]>
<![%html;[
;; customize the html stylesheet here
]]>
</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>
不同的 style-specification 具有不同的 ID,
另外还有参数实体控制
另外还有参数实体控制
<!DOCTYPE style-sheet PUBLIC
"-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN"
CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"
CDATA dsssl>
]]>
]>
<style-sheet>
<style-specification id="print" use="docbook">
<style-specification-body>
;; customize the print stylesheet
...
</style-specification-body>
</style-specification>
<!--
;; customize the html stylesheet; parts borrowed from
;; Cygnus at http://sourceware.cygnus.com/ (cygnus-both.dsl)
-->
<style-specification id="html" use="docbook">
<style-specification-body>
... ...
</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>
"-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY % html "IGNORE">
<![%html;[
<!ENTITY % print "IGNORE">
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN"
CDATA dsssl>
]]>
<!ENTITY % print "INCLUDE">
<![%print;[
<!ENTITY docbook.dsl PUBLIC
"-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"
CDATA dsssl>
]]>
]>
<style-sheet>
<style-specification id="print" use="docbook">
<style-specification-body>
;; customize the print stylesheet
...
</style-specification-body>
</style-specification>
<!--
;; customize the html stylesheet; parts borrowed from
;; Cygnus at http://sourceware.cygnus.com/ (cygnus-both.dsl)
-->
<style-specification id="html" use="docbook">
<style-specification-body>
... ...
</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>
格式转换
(命令行示例)
(命令行示例)
sgml -> single html
sgml -> multiple htmls
XML
xml -> single html
测试用例
test.sh
#!/bin/sh
SRCROOT=../../src
# onsgml test...
echo -ne "validate gb2312.sgml, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml gb2312.sgml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate utf8.sgml, ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml utf8.sgml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate gb2312.xml, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate utf8.xml, ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "gb2312.sgml is NOT valid IF VALIDATED AS XML, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.sgml 2>/dev/null
[ $? -ne 0 ] && echo "pass" || echo "failed"
# osx test...
echo -ne "osx convert test, gb2312.sgml->gb2312.xml, ... "
tmpfile=`mktemp tmp-gb-xml.XXXXX`
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 osx -x preserve-case -x comment -c ${SRCROOT}/catalog.sgml gb2312.sgml | iconv -f utf-8 -t gb2312 > $tmpfile
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl $tmpfile
[ -f $tmpfile ] && rm $tmpfile
echo "pass"
# openjade test...
echo -ne "convert gb2312.sgml to multiple htmls, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -t sgml gb2312.sgml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.sgml to one big html, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -V nochunks -t sgml gb2312.sgml > gb2312-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.sgml to rtf, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/print/docbook.dsl -t rtf gb2312.sgml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to multiple htmls (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -t sgml utf8.sgml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to one big html (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -V nochunks -t sgml utf8.sgml > utf8-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to rtf (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#print -i print -t rtf utf8.sgml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
# openjade XML test...
echo -ne "convert gb2312.xml to multiple htmls, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.xml to one big html, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -V nochunks -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml > gb2312-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.xml to rtf, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/print/docbook.dsl -t rtf ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to multiple htmls (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to one big html (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -V nochunks -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml > utf8-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to rtf (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#print -i print -t rtf ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
SRCROOT=../../src
# onsgml test...
echo -ne "validate gb2312.sgml, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml gb2312.sgml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate utf8.sgml, ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml utf8.sgml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate gb2312.xml, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "validate utf8.xml, ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "gb2312.sgml is NOT valid IF VALIDATED AS XML, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.sgml 2>/dev/null
[ $? -ne 0 ] && echo "pass" || echo "failed"
# osx test...
echo -ne "osx convert test, gb2312.sgml->gb2312.xml, ... "
tmpfile=`mktemp tmp-gb-xml.XXXXX`
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 osx -x preserve-case -x comment -c ${SRCROOT}/catalog.sgml gb2312.sgml | iconv -f utf-8 -t gb2312 > $tmpfile
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 onsgmls -s -c ${SRCROOT}/catalog.sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl $tmpfile
[ -f $tmpfile ] && rm $tmpfile
echo "pass"
# openjade test...
echo -ne "convert gb2312.sgml to multiple htmls, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -t sgml gb2312.sgml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.sgml to one big html, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -V nochunks -t sgml gb2312.sgml > gb2312-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.sgml to rtf, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/print/docbook.dsl -t rtf gb2312.sgml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to multiple htmls (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -t sgml utf8.sgml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to one big html (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -V nochunks -t sgml utf8.sgml > utf8-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.sgml to rtf (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#print -i print -t rtf utf8.sgml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
# openjade XML test...
echo -ne "convert gb2312.xml to multiple htmls, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.xml to one big html, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/html/docbook.dsl -V nochunks -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml > gb2312-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert gb2312.xml to rtf, ... "
SP_ENCODING=gb2312 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/docbook-dsssl-1.79/print/docbook.dsl -t rtf ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl gb2312.xml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to multiple htmls (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
#rm t1.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to one big html (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#html -i html -i charset.utf8 -V nochunks -t sgml ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml > utf8-sgml.htm
#rm index.htm
[ $? -eq 0 ] && echo "pass" || echo "failed"
echo -ne "convert utf8.xml to rtf (ldap.dsl), ... "
SP_ENCODING=utf-8 SP_CHARSET_FIXED=1 openjade -c ${SRCROOT}/catalog.sgml -d ${SRCROOT}/dsssl/ldp.dsl\#print -i print -t rtf ${SRCROOT}/dsssl/docbook-dsssl-1.79/dtds/decls/xml.dcl utf8.xml
#rm gb2312.rtf
[ $? -eq 0 ] && echo "pass" || echo "failed"
XML 时代的 DocBook
XSL
HTML 输出的参数控制
分页
可打印版本输出的参数控制
样式表定制层
Customization layers
Customization layers
定制层可以实现
属性集合定制
何为属性集合
如
<xsl:attribute-set name="section.title.properties">
<xsl:attribute name="font-family">
<xsl:value-of select="$title.font.family"/>
</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<!-- font size is calculated dynamically by section.heading template -->
<xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
<xsl:attribute name="space-before.optimum">1.0em</xsl:attribute>
<xsl:attribute name="space-before.maximum">1.2em</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute name="font-family">
<xsl:value-of select="$title.font.family"/>
</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<!-- font size is calculated dynamically by section.heading template -->
<xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
<xsl:attribute name="space-before.optimum">1.0em</xsl:attribute>
<xsl:attribute name="space-before.maximum">1.2em</xsl:attribute>
</xsl:attribute-set>
充实占位模板
其它占位模板,如:
user.preroot
user.head.content
添加 CSS 等
<xsl:param name="target.window" select="'_self'"/>
<xsl:template name="user.head.content">
<xsl:comment> (c) 2002 Copyright Megacorp, Inc. </xsl:comment>
<base target="{$target.window}"/>
<style type="text/css">
<xsl:comment>
@import "stylesheets/override.css"
body {background: url(graphics/bluesea.png);}
</xsl:comment>
</style>
</xsl:template>
<xsl:template name="user.head.content">
<xsl:comment> (c) 2002 Copyright Megacorp, Inc. </xsl:comment>
<base target="{$target.window}"/>
<style type="text/css">
<xsl:comment>
@import "stylesheets/override.css"
body {background: url(graphics/bluesea.png);}
</xsl:comment>
</style>
</xsl:template>
替换样式模板
例如: 替换 body.attributes 模板,
为 body 增加属性定义
为 body 增加属性定义
<xsl:template name="body.attributes">
<xsl:attribute name="onLoad">alert('Thanks for visiting')</xsl:attribute>
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
<xsl:attribute name="onLoad">alert('Thanks for visiting')</xsl:attribute>
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
本地化设置
定制中文姓名显示方式
定制 family-given 模板
<xsl:template name="person.name.family-given">
<xsl:param name="node" select="."/>
<xsl:if test="$node//surname">
<xsl:apply-templates select="$node//surname[1]"/>
</xsl:if>
<xsl:if test="$node//othername and $author.othername.in.middle != 0">
<xsl:if test="$node//surname">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="$node//othername[1]"/>
</xsl:if>
<xsl:if test="$node//firstname">
<xsl:if test="$node//surname
or ($node//othername and $author.othername.in.middle != 0)">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="$node//firstname[1]"/>
</xsl:if>
<xsl:if test="$node//lineage">
<xsl:text>, </xsl:text>
<xsl:apply-templates select="$node//lineage[1]"/>
</xsl:if>
<xsl:if test="$node//honorific">
<xsl:text> </xsl:text>
<xsl:apply-templates select="$node//honorific[1]"/>
<xsl:value-of select="$punct.honorific"/>
</xsl:if>
</xsl:template>
<xsl:param name="node" select="."/>
<xsl:if test="$node//surname">
<xsl:apply-templates select="$node//surname[1]"/>
</xsl:if>
<xsl:if test="$node//othername and $author.othername.in.middle != 0">
<xsl:if test="$node//surname">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="$node//othername[1]"/>
</xsl:if>
<xsl:if test="$node//firstname">
<xsl:if test="$node//surname
or ($node//othername and $author.othername.in.middle != 0)">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="$node//firstname[1]"/>
</xsl:if>
<xsl:if test="$node//lineage">
<xsl:text>, </xsl:text>
<xsl:apply-templates select="$node//lineage[1]"/>
</xsl:if>
<xsl:if test="$node//honorific">
<xsl:text> </xsl:text>
<xsl:apply-templates select="$node//honorific[1]"/>
<xsl:value-of select="$punct.honorific"/>
</xsl:if>
</xsl:template>
示例
定制 fo
示例
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="fo/docbook.xsl"/>
<xsl:template match="lineannotation">
<fo:inline font-style="italic">
<xsl:call-template name="inline.charseq"/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="fo/docbook.xsl"/>
<xsl:template match="lineannotation">
<fo:inline font-style="italic">
<xsl:call-template name="inline.charseq"/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
Catalog
Catalog 文件在哪?
Saxon
创建文件 CatalogManager.properties
命令行示例
java -cp "/usr/java/saxon.jar:/docbook-xsl/extensions/saxon653.jar:\
/usr/share/resolver.jar;/usr/share" \
com.icl.saxon.StyleSheet \
-x org.apache.xml.resolver.tools.ResolvingXMLReader \
-y org.apache.xml.resolver.tools.ResolvingXMLReader \
-r org.apache.xml.resolver.tools.CatalogResolver \
-u \
-o myfile.html \
myfile.xml docbook.xsl
/usr/share/resolver.jar;/usr/share" \
com.icl.saxon.StyleSheet \
-x org.apache.xml.resolver.tools.ResolvingXMLReader \
-y org.apache.xml.resolver.tools.ResolvingXMLReader \
-r org.apache.xml.resolver.tools.CatalogResolver \
-u \
-o myfile.html \
myfile.xml docbook.xsl
Xalan
命令行为
java -cp "/usr/java/xerces.jar:/usr/java/xalan.jar:\
/docbook-xsl/extensions/xalan25.jar:\
/usr/share/resolver.jar:/usr/share" \
org.apache.xalan.xslt.Process \
-ENTITYRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
-URIRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
-out myfile.html \
-in myfile.xml \
-xsl http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
/docbook-xsl/extensions/xalan25.jar:\
/usr/share/resolver.jar:/usr/share" \
org.apache.xalan.xslt.Process \
-ENTITYRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
-URIRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
-out myfile.html \
-in myfile.xml \
-xsl http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
示例
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<!-- DTD and stylesheet files installed under /usr/share/xml -->
<group xml:base="file:///usr/share/xml/" >
<!-- Resolve DTD URL system ID to local file -->
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="docbook44/" />
<!-- Resolve stylesheet URL to local file -->
<rewriteURI
uriStartString="http://docbook.sourceforge.net/release/xsl/current/"
rewritePrefix="docbook-xsl-1.68.1/" />
<!-- Resolve DTD PUBLIC identifiers -->
<nextCatalog catalog="docbook44/catalog.xml" />
<!-- To resolve simple DTD SYSTEM identifiers. -->
<!-- Note: this does not work with Java resolver -->
<!-- classes in Saxon or Xalan -->
<system
systemId="docbook.dtd"
uri="docbook44/docbookx.dtd" />
<!-- To resolve short stylesheet references -->
<uri
name="docbook.xsl"
uri="docbook-xsl-1.68.1/html/docbook.xsl" />
<uri
name="chunk.xsl"
uri="docbook-xsl-1.68.1/html/chunk.xsl" />
<uri
name="fo-docbook.xsl"
uri="docbook-xsl-1.68.1/fo/docbook.xsl" />
</group>
</catalog>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<!-- DTD and stylesheet files installed under /usr/share/xml -->
<group xml:base="file:///usr/share/xml/" >
<!-- Resolve DTD URL system ID to local file -->
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="docbook44/" />
<!-- Resolve stylesheet URL to local file -->
<rewriteURI
uriStartString="http://docbook.sourceforge.net/release/xsl/current/"
rewritePrefix="docbook-xsl-1.68.1/" />
<!-- Resolve DTD PUBLIC identifiers -->
<nextCatalog catalog="docbook44/catalog.xml" />
<!-- To resolve simple DTD SYSTEM identifiers. -->
<!-- Note: this does not work with Java resolver -->
<!-- classes in Saxon or Xalan -->
<system
systemId="docbook.dtd"
uri="docbook44/docbookx.dtd" />
<!-- To resolve short stylesheet references -->
<uri
name="docbook.xsl"
uri="docbook-xsl-1.68.1/html/docbook.xsl" />
<uri
name="chunk.xsl"
uri="docbook-xsl-1.68.1/html/chunk.xsl" />
<uri
name="fo-docbook.xsl"
uri="docbook-xsl-1.68.1/fo/docbook.xsl" />
</group>
</catalog>
XInclude
XInclude示例
文件 index.xml
(包含 intro.xml)
(包含 intro.xml)
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book>
<title>User Guide</title>
<para>This guide shows you how to use the software.</para>
<xi:include
xmlns:xi="http://www.w3.org/2001/XInclude" href="intro.xml" />
...
</book>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book>
<title>User Guide</title>
<para>This guide shows you how to use the software.</para>
<xi:include
xmlns:xi="http://www.w3.org/2001/XInclude" href="intro.xml" />
...
</book>
XInclude语法要点
entities
示例
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!ENTITY intro "part1/intro.xml">
<!ENTITY basics "part1/getting_started.xml">
<!ENTITY config "admin/configuring_the_server.xml">
<!ENTITY advanced "admin/advanced_user_moves.xml">
]>
<book>
<title>User Guide</title>
<para>This guide shows you how to use the software.</para>
<xi:include href="&intro;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&basics;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&config;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&advanced;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
...
</book>
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!ENTITY intro "part1/intro.xml">
<!ENTITY basics "part1/getting_started.xml">
<!ENTITY config "admin/configuring_the_server.xml">
<!ENTITY advanced "admin/advanced_user_moves.xml">
]>
<book>
<title>User Guide</title>
<para>This guide shows you how to use the software.</para>
<xi:include href="&intro;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&basics;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&config;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="&advanced;" xmlns:xi="http://www.w3.org/2001/XInclude"/>
...
</book>
Xalan
fop
中文支持问题
xsl 定制
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:import href="C:/docbook/docbook-xsl-1.68.1/fo/docbook.xsl"/>
<xsl:param name="fop.extensions" select="1" />
<xsl:param name="variablelist.as.blocks" select="1" />
<xsl:param name="chunker.output.encoding" select="'utf-8'" />
<xsl:param name="use.extensions" select="1" />
<xsl:param name="l10n.gentext.language" select="'zh_cn'" />
<xsl:param name="admon.graphics" select="1" />
<!--xsl:param name="draft.watermark.image" select="images/draft.png"></xsl:param-->
<xsl:param name="body.font.family">SimSun</xsl:param>
<xsl:param name="title.font.family">SimSun</xsl:param>
</xsl:stylesheet>
<xsl:import href="C:/docbook/docbook-xsl-1.68.1/fo/docbook.xsl"/>
<xsl:param name="fop.extensions" select="1" />
<xsl:param name="variablelist.as.blocks" select="1" />
<xsl:param name="chunker.output.encoding" select="'utf-8'" />
<xsl:param name="use.extensions" select="1" />
<xsl:param name="l10n.gentext.language" select="'zh_cn'" />
<xsl:param name="admon.graphics" select="1" />
<!--xsl:param name="draft.watermark.image" select="images/draft.png"></xsl:param-->
<xsl:param name="body.font.family">SimSun</xsl:param>
<xsl:param name="title.font.family">SimSun</xsl:param>
</xsl:stylesheet>
fop 配置,增加中文字体
我们需要userconfig.xml来改变编译FO到PDF的一些默认属性,因为我们需要中文字体,需要用ttfreader.cmd来生成字体文件,这里我已经生成了文件在fonts目录下。然后建立userconfig.xml文件
userconfig.xml
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<!--
this file contains templates which allow an user easy
configuration of Fop. Actually normally you don't need this configuration
file, but if you need to change configuration, you should
always use this file and *not* config.xml.
Usage: java org.apache.fop.apps.Fop -c userconfig.xml -fo fo-file -pdf pdf-file
-->
<configuration>
<!--
baseDir: normally the base directory is the directory where the fo file is
located. if you want to specify your own, uncomment this entry.
This value can also be a URL. Actually, the value is converted to
a URL.
-->
<!--
<entry>
<key>baseDir</key>
<value></value>
</entry>
-->
<!--
fontBaseDir: Similar to baseDir, except that this value is used for fonts. If
it isn't specified, the value from baseDir is used.
-->
<!--
<entry>
<key>fontBaseDir</key>
<value></value>
</entry>
-->
<!--
************************************************************************
HYPHENATION
************************************************************************
-->
<!--
hyphenation directory
if you want to specify your own directory with hyphenation pattern
then uncomment the next entry and add the directory name
-->
<!--
<entry>
<key>hyphenation-dir</key>
<value>/java/xml-fop/hyph</value>
</entry>
-->
<!--
************************************************************************
Add fonts here
************************************************************************
-->
<fonts>
<!-- example -->
<font metrics-file="fonts\simfang.xml" kerning="yes" embed-file="C:\WINDOWS\Fonts\simfang.ttf">
<font-triplet name="FangSong_GB2312" style="normal" weight="normal"/>
</font>
<!--
<font metrics-file="arialb.xml" kerning="yes" embed-file="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
<font metrics-file="ariali.xml" kerning="yes" embed-file="ariali.ttf">
<font-triplet name="Arial" style="italic" weight="normal"/>
<font-triplet name="ArialMT" style="italic" weight="normal"/>
</font>
<font metrics-file="arialbi.xml" kerning="yes" embed-file="arialbi.ttf">
<font-triplet name="Arial" style="italic" weight="bold"/>
<font-triplet name="ArialMT" style="italic" weight="bold"/>
</font>
-->
<font metrics-file="fonts\simsun.xml" embed-file="C:\windows\fonts\simsun.ttc" kerning="yes">
<font-triplet name="SimSun" style="normal" weight="normal"/>
<font-triplet name="SimSun" style="normal" weight="bold"/>
<font-triplet name="NSimSun" style="italic" weight="normal"/>
<font-triplet name="NSimSun" style="italic" weight="bold"/>
</font>
<!-- Example Japanese fonts
<font metrics-file="msmincho.xml" embed-file="Cyberbit.ttf" kerning="yes">
<font-triplet name="Mincho" style="normal" weight="normal"/>
<font-triplet name="Mincho" style="normal" weight="bold"/>
<font-triplet name="Mincho" style="italic" weight="normal"/>
<font-triplet name="Mincho" style="italic" weight="bold"/>
</font>
-->
</fonts>
</configuration>
<!--
this file contains templates which allow an user easy
configuration of Fop. Actually normally you don't need this configuration
file, but if you need to change configuration, you should
always use this file and *not* config.xml.
Usage: java org.apache.fop.apps.Fop -c userconfig.xml -fo fo-file -pdf pdf-file
-->
<configuration>
<!--
baseDir: normally the base directory is the directory where the fo file is
located. if you want to specify your own, uncomment this entry.
This value can also be a URL. Actually, the value is converted to
a URL.
-->
<!--
<entry>
<key>baseDir</key>
<value></value>
</entry>
-->
<!--
fontBaseDir: Similar to baseDir, except that this value is used for fonts. If
it isn't specified, the value from baseDir is used.
-->
<!--
<entry>
<key>fontBaseDir</key>
<value></value>
</entry>
-->
<!--
************************************************************************
HYPHENATION
************************************************************************
-->
<!--
hyphenation directory
if you want to specify your own directory with hyphenation pattern
then uncomment the next entry and add the directory name
-->
<!--
<entry>
<key>hyphenation-dir</key>
<value>/java/xml-fop/hyph</value>
</entry>
-->
<!--
************************************************************************
Add fonts here
************************************************************************
-->
<fonts>
<!-- example -->
<font metrics-file="fonts\simfang.xml" kerning="yes" embed-file="C:\WINDOWS\Fonts\simfang.ttf">
<font-triplet name="FangSong_GB2312" style="normal" weight="normal"/>
</font>
<!--
<font metrics-file="arialb.xml" kerning="yes" embed-file="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
<font metrics-file="ariali.xml" kerning="yes" embed-file="ariali.ttf">
<font-triplet name="Arial" style="italic" weight="normal"/>
<font-triplet name="ArialMT" style="italic" weight="normal"/>
</font>
<font metrics-file="arialbi.xml" kerning="yes" embed-file="arialbi.ttf">
<font-triplet name="Arial" style="italic" weight="bold"/>
<font-triplet name="ArialMT" style="italic" weight="bold"/>
</font>
-->
<font metrics-file="fonts\simsun.xml" embed-file="C:\windows\fonts\simsun.ttc" kerning="yes">
<font-triplet name="SimSun" style="normal" weight="normal"/>
<font-triplet name="SimSun" style="normal" weight="bold"/>
<font-triplet name="NSimSun" style="italic" weight="normal"/>
<font-triplet name="NSimSun" style="italic" weight="bold"/>
</font>
<!-- Example Japanese fonts
<font metrics-file="msmincho.xml" embed-file="Cyberbit.ttf" kerning="yes">
<font-triplet name="Mincho" style="normal" weight="normal"/>
<font-triplet name="Mincho" style="normal" weight="bold"/>
<font-triplet name="Mincho" style="italic" weight="normal"/>
<font-triplet name="Mincho" style="italic" weight="bold"/>
</font>
-->
</fonts>
</configuration>
DocBook 元素参考
词汇修饰
视窗对象
其它类似元素:
guibutton, guiicon, guilabel, guimenu, guimenuitem, guisubmenu, keycap, keycode, keycombo, keysym, menuchoice, mousebutton, shortcut
guibutton, guiicon, guilabel, guimenu, guimenuitem, guisubmenu, keycap, keycode, keycombo, keysym, menuchoice, mousebutton, shortcut
guiicon
例如
<para>The exact text of the <guilabel>Legend</guilabel> and other labels on the
graph is dependent upon the language of the current locale. Likewise,
the text of the <guibutton>OK</guibutton> button and other buttons may vary.
The <guiicon><inlinemediaobject>
<imageobject>
<imagedata fileref="figures/legend.png"/>
</imageobject>
</inlinemediaobject></guiicon>
icon and the other icons on the left side of the display may be
configured by the local administrator, but they are not
generally expected to vary from locale to locale.
</para>
graph is dependent upon the language of the current locale. Likewise,
the text of the <guibutton>OK</guibutton> button and other buttons may vary.
The <guiicon><inlinemediaobject>
<imageobject>
<imagedata fileref="figures/legend.png"/>
</imageobject>
</inlinemediaobject></guiicon>
icon and the other icons on the left side of the display may be
configured by the local administrator, but they are not
generally expected to vary from locale to locale.
</para>
建立链接
link
如果 link 元素没有内容,并且具有 endterm 属性,将 endterm 指向的元素的值,拷贝到 link 处,并作为热点文字,指向 linkend 指向的文档内部的 endterm 指向的链接;
例如
<sect1><title>Examples of <sgmltag>Link</sgmltag></title>
<para>
In this sentence <link linkend='nextsect'>this</link> word is
hot and points to the following section.
</para>
<para>
There is also a link to the section called
<quote><link linkend='nextsect' endterm="nextsect.title"/></quote>
in this sentence.
</para>
<sect2 id='nextsect'><title id='nextsect.title'>A Subsection</title>
<para>
This section only exists to be the target of a couple of links.
</para>
</sect2>
</sect1>
<para>
In this sentence <link linkend='nextsect'>this</link> word is
hot and points to the following section.
</para>
<para>
There is also a link to the section called
<quote><link linkend='nextsect' endterm="nextsect.title"/></quote>
in this sentence.
</para>
<sect2 id='nextsect'><title id='nextsect.title'>A Subsection</title>
<para>
This section only exists to be the target of a couple of links.
</para>
</sect2>
</sect1>
表格
table
示例
<table frame='all'><title>Sample Table</title>
<tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'/>
<colspec colname='c2'/>
<colspec colname='c3'/>
<colspec colnum='5' colname='c5'/>
<thead>
<row>
<entry namest="c1" nameend="c2" align="center">Horizontal Span</entry>
<entry>a3</entry>
<entry>a4</entry>
<entry>a5</entry>
</row>
</thead>
<tfoot>
<row>
<entry>f1</entry>
<entry>f2</entry>
<entry>f3</entry>
<entry>f4</entry>
<entry>f5</entry>
</row>
</tfoot>
<tbody>
<row>
<entry>b1</entry>
<entry>b2</entry>
<entry>b3</entry>
<entry>b4</entry>
<entry morerows='1' valign='middle'><para> <!-- Pernicous Mixed Content -->
Vertical Span</para></entry>
</row>
<row>
<entry>c1</entry>
<entry namest="c2" nameend="c3" align='center' morerows='1' valign='bottom'>Span Both</entry>
<entry>c4</entry>
</row>
<row>
<entry>d1</entry>
<entry>d4</entry>
<entry>d5</entry>
</row>
</tbody>
</tgroup>
</table>
<tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'/>
<colspec colname='c2'/>
<colspec colname='c3'/>
<colspec colnum='5' colname='c5'/>
<thead>
<row>
<entry namest="c1" nameend="c2" align="center">Horizontal Span</entry>
<entry>a3</entry>
<entry>a4</entry>
<entry>a5</entry>
</row>
</thead>
<tfoot>
<row>
<entry>f1</entry>
<entry>f2</entry>
<entry>f3</entry>
<entry>f4</entry>
<entry>f5</entry>
</row>
</tfoot>
<tbody>
<row>
<entry>b1</entry>
<entry>b2</entry>
<entry>b3</entry>
<entry>b4</entry>
<entry morerows='1' valign='middle'><para> <!-- Pernicous Mixed Content -->
Vertical Span</para></entry>
</row>
<row>
<entry>c1</entry>
<entry namest="c2" nameend="c3" align='center' morerows='1' valign='bottom'>Span Both</entry>
<entry>c4</entry>
</row>
<row>
<entry>d1</entry>
<entry>d4</entry>
<entry>d5</entry>
</row>
</tbody>
</tgroup>
</table>
Example
example
示例
<example><title>A DSSSL Function</title>
<programlisting>
(define (node-list-filter-by-gi nodelist gilist)
;; Returns the node-list that contains every element of the original
;; nodelist whose gi is in gilist
(let loop ((result (empty-node-list)) (nl nodelist))
(if (node-list-empty? nl)
result
(if (member (gi (node-list-first nl)) gilist)
(loop (node-list result (node-list-first nl))
(node-list-rest nl))
(loop result (node-list-rest nl))))))
</programlisting>
</example>
<programlisting>
(define (node-list-filter-by-gi nodelist gilist)
;; Returns the node-list that contains every element of the original
;; nodelist whose gi is in gilist
(let loop ((result (empty-node-list)) (nl nodelist))
(if (node-list-empty? nl)
result
(if (member (gi (node-list-first nl)) gilist)
(loop (node-list result (node-list-first nl))
(node-list-rest nl))
(loop result (node-list-rest nl))))))
</programlisting>
</example>
DocBook Website
website 的 DTD
在 catalog.xml 添加条目
<nextCatalog catalog="website/2.6.0/catalog.xml" />
<!-- 由于 website DTD 中用到了 4.4 版本的 DocBook DTD, 故有如下定义-->
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="dtd/docbook-4.5/" />
<rewriteSystem
systemIdStartString="http://docbook.org/xml/4.4/"
rewritePrefix="dtd/docbook-4.5/" />
<!-- 由于 website DTD 中用到了 4.4 版本的 DocBook DTD, 故有如下定义-->
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook/xml/4.4/"
rewritePrefix="dtd/docbook-4.5/" />
<rewriteSystem
systemIdStartString="http://docbook.org/xml/4.4/"
rewritePrefix="dtd/docbook-4.5/" />
layout.xml 文件
tocentry 元素
更多示例
<toc page="website.xml"
filename="index.html">
<tocentry page="wslayout.xml"
revisionflag="changed"
filename="layout.html"/>
<tocentry page="olink.xml"
filename="linking.html"/>
<tocentry page="custom.xml"
filename="custom.html"/>
<tocentry page="building.xml"
filename="building.html"
tocskip='1'>
<tocentry page="build-make.xml"
filename="buildmake.html"
dir="build"/>
<tocentry page="build-ext.xml"
filename="buildext.html"
dir="build"/>
<tocentry page="build-textonly.xml"
filename="textonly.html"
dir="build"/>
</tocentry>
<tocentry page="test2.xml"
filename="formtest.html"/>
...
</toc>
filename="index.html">
<tocentry page="wslayout.xml"
revisionflag="changed"
filename="layout.html"/>
<tocentry page="olink.xml"
filename="linking.html"/>
<tocentry page="custom.xml"
filename="custom.html"/>
<tocentry page="building.xml"
filename="building.html"
tocskip='1'>
<tocentry page="build-make.xml"
filename="buildmake.html"
dir="build"/>
<tocentry page="build-ext.xml"
filename="buildext.html"
dir="build"/>
<tocentry page="build-textonly.xml"
filename="textonly.html"
dir="build"/>
</tocentry>
<tocentry page="test2.xml"
filename="formtest.html"/>
...
</toc>
网页之间的链接: olink
两种编译方式
Makefile 编译
Makefile 示例
PROC = XML_CATALOG_FILES=/docbook/src/catalog.xml xsltproc --nonet
XSLPATH = /docbook/src/xsl/docbook-xsl-1.69.1/website
all:
make website
include depends.tabular
autolayout.xml: layout.xml
$(PROC) \
--output $@ \
$(XSLPATH)/autolayout.xsl $<
make depends
depends: autolayout.xml
$(PROC) \
--output depends.tabular \
--stringparam output-root htdocs \
$(XSLPATH)/makefile-dep.xsl $<
website.database.xml: autolayout.xml
$(PROC) \
--output $@ \
$(XSLPATH)/website-targets.xsl $<
%.html: autolayout.xml
$(PROC) \
--output $@ \
--stringparam website.database.document website.database.xml \
--stringparam output-root htdocs \
$(XSLPATH)/tabular.xsl \
$(filter-out autolayout.xml,$^)
XSLPATH = /docbook/src/xsl/docbook-xsl-1.69.1/website
all:
make website
include depends.tabular
autolayout.xml: layout.xml
$(PROC) \
--output $@ \
$(XSLPATH)/autolayout.xsl $<
make depends
depends: autolayout.xml
$(PROC) \
--output depends.tabular \
--stringparam output-root htdocs \
$(XSLPATH)/makefile-dep.xsl $<
website.database.xml: autolayout.xml
$(PROC) \
--output $@ \
$(XSLPATH)/website-targets.xsl $<
%.html: autolayout.xml
$(PROC) \
--output $@ \
--stringparam website.database.document website.database.xml \
--stringparam output-root htdocs \
$(XSLPATH)/tabular.xsl \
$(filter-out autolayout.xml,$^)
DocBook XSL 解密
website
tabular.xsl
模板 <xsl:template match="webpage">
<xsl:call-template name="body.attributes"/>
html/docbook.xsl
定义样式
<xsl:template name="body.attributes">
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
<xsl:template name="body.attributes">
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
website-common.xsl
param.xsl
feedback
<xsl:param name="feedback.href"/>
<xsl:param name="feedback.with.ids" select="0"/>
<xsl:param name="feedback.link.text">Feedback</xsl:param>
导航条
<xsl:param name="banner.before.navigation" select="1"/>
<xsl:param name="navtocwidth">220</xsl:param>
<xsl:param name="navbodywidth"/>
<xsl:param name="navbgcolor">#4080FF</xsl:param>
<xsl:param name="textbgcolor">white</xsl:param>
<xsl:param name="toc.spacer.graphic" select="1"/>
<xsl:param name="toc.spacer.text"> </xsl:param>
<xsl:param name="toc.spacer.image">graphics/blank.gif</xsl:param>
<xsl:param name="toc.pointer.graphic" select="1"/>
<xsl:param name="toc.pointer.text"> > </xsl:param>
<xsl:param name="toc.pointer.image">graphics/arrow.gif</xsl:param>
<xsl:param name="toc.blank.graphic" select="1"/>
<xsl:param name="toc.blank.text"> </xsl:param>
<xsl:param name="toc.blank.image">graphics/blank.gif</xsl:param>
website.xsl
模板 <xsl:template match="webpage">
<xsl:call-template name="body.attributes"/>
html/docbook.xsl
定义样式
<xsl:template name="body.attributes">
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
<xsl:template name="body.attributes">
<xsl:attribute name="bgcolor">white</xsl:attribute>
<xsl:attribute name="text">black</xsl:attribute>
<xsl:attribute name="link">#0000FF</xsl:attribute>
<xsl:attribute name="vlink">#840084</xsl:attribute>
<xsl:attribute name="alink">#0000FF</xsl:attribute>
</xsl:template>
chunk-common.xsl
OSX 定制
模板 template/layout.xml
config
<config param="homebanner-tabular" value="/images/logo/homebanner.png"
altval="Home Banner"/>
<config param="banner-tabular" value="/images/logo/banner.png"
altval="Banner"/>
<config param="homebanner" value="/images/logo/homebanner.png"
altval="Home Banner"/>
<config param="banner" value="/images/logo/iconhome.gif"
altval="Banner"/>
<config param="navbgcolor" value="#4080FF"/>
<config param="footer" value="http://www.worldhello.net" altval="FT:WorldHello"/>
<config param="footlink" value="about" altval="FL:关于"/>
<config param="feedback.href" value="webmaster@mysite.com"/>
altval="Home Banner"/>
<config param="banner-tabular" value="/images/logo/banner.png"
altval="Banner"/>
<config param="homebanner" value="/images/logo/homebanner.png"
altval="Home Banner"/>
<config param="banner" value="/images/logo/iconhome.gif"
altval="Banner"/>
<config param="navbgcolor" value="#4080FF"/>
<config param="footer" value="http://www.worldhello.net" altval="FT:WorldHello"/>
<config param="footlink" value="about" altval="FL:关于"/>
<config param="feedback.href" value="webmaster@mysite.com"/>
osx-common.xsl
是否用水平分隔线分隔正文于 header 和 footer
<xsl:param name="header.hr" select="1"/>
<xsl:param name="footer.hr" select="1"/>
导航条以及正文的背景颜色设置
<xsl:param name="textbgcolor">white</xsl:param>
<xsl:param name="navbgcolor">#4080FF</xsl:param>
以图标方式显示警告
<xsl:param name="admon.graphics" select="1"/>
<xsl:param name="admon.textlabel" select="0"/>
<xsl:param name="admon.graphics.path">/images/docbook/</xsl:param>
<xsl:param name="admon.graphics.extension">.png</xsl:param>
以图标方式显示导航
<xsl:param name="navig.graphics" select="1"/>
<xsl:param name="navig.graphics.path">/images/docbook/</xsl:param>
<xsl:param name="navig.graphics.extension">.png</xsl:param>
以图标方式显示 callout
<xsl:param name="callout.graphics" select="1"/>
<xsl:param name="callout.graphics.path">/images/callouts/</xsl:param>
<xsl:param name="callout.graphics.extension">.png</xsl:param>
<xsl:param name="callout.graphics.number.limit">15</xsl:param>
其它图片
<xsl:param name="toc.spacer.image">/images/docbook/blank.png</xsl:param>
<xsl:param name="toc.pointer.image">/images/docbook/arrow.png</xsl:param>
<xsl:param name="toc.blank.image">/images/docbook/blank.png</xsl:param>
<xsl:param name="table.spacer.image">/images/docbook/spacer.png</xsl:param>
<xsl:param name="nav.icon.path">/images/navicons/</xsl:param>
是否章节编号
<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="section.label.includes.component.label" select="1"/>
<xsl:param name="section.autolabel.max.depth" select="8"/>
参数定制
<xsl:import href="chunk-tabular.xsl"/>
<!-- Website stylesheet parameters -->
<xsl:param name="footer.hr" select="0"/>
<xsl:param name="feedback.link.text">Send us feedback</xsl:param>
<xsl:param name="textbgcolor">#C8C8C8</xsl:param>
<!-- DocBook stylesheet parameters -->
<xsl:param name="admon.graphics" select="1"/>
<!-- Website stylesheet parameters -->
<xsl:param name="footer.hr" select="0"/>
<xsl:param name="feedback.link.text">Send us feedback</xsl:param>
<xsl:param name="textbgcolor">#C8C8C8</xsl:param>
<!-- DocBook stylesheet parameters -->
<xsl:param name="admon.graphics" select="1"/>
GIMP 风格 website
netfilter
website xsl
mine.xsl
DocBook
l10n
common/l10n.xsl
<xsl:param name="l10n.xml" select="document('../common/l10n.xml')"/>
<xsl:param name="local.l10n.xml" select="document('')"/>
<xsl:param name="local.l10n.xml" select="document('')"/>
<xsl:template name="gentext.nav.home">
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'nav-home'"/>
</xsl:call-template>
</xsl:template>
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'nav-home'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="gentext">
调试 l10n
在文件 common/l10n.xsl 的 gentext 模板中,添加 <xsl:message> 诊断元素
<xsl:template name="gentext">
...
<xsl:if test="$key = 'nav-home'">
<xsl:message terminate="yes">
language: <xsl:value-of select="$lang"/>,
local.l10n.gentext: <xsl:value-of select="$local.l10n.gentext/@text"/>,
l10n.gentext: <xsl:value-of select="$l10n.gentext/@text"/>
</xsl:message>
</xsl:if>
<xsl:template name="gentext">
...
<xsl:if test="$key = 'nav-home'">
<xsl:message terminate="yes">
language: <xsl:value-of select="$lang"/>,
local.l10n.gentext: <xsl:value-of select="$local.l10n.gentext/@text"/>,
l10n.gentext: <xsl:value-of select="$l10n.gentext/@text"/>
</xsl:message>
</xsl:if>
olink
target.database.filename
示例
<targetset>
<document targetdoc="osx" baseuri="http://www.OpenSourceXpress.com">
<div href="/" targetptr="full">
<xreftext>北京群英汇信息技术有限公司</xreftext>
</div>
<div href="/" targetptr="short">
<xreftext>群英汇</xreftext>
</div>
<div href="/" targetptr="web">
<xreftext>http://www.OpenSourceXpress.com/</xreftext>
</div>
</document>
</targetset>
<document targetdoc="osx" baseuri="http://www.OpenSourceXpress.com">
<div href="/" targetptr="full">
<xreftext>北京群英汇信息技术有限公司</xreftext>
</div>
<div href="/" targetptr="short">
<xreftext>群英汇</xreftext>
</div>
<div href="/" targetptr="web">
<xreftext>http://www.OpenSourceXpress.com/</xreftext>
</div>
</document>
</targetset>
人物
FOP
需要的软件
FOP 版本
0.91beta
fop 中 cygpath,会遇到 filename too long 的问题!
函数 mycygpath
function mycygpath()
{
ARGS=""
PATHSEPT=":"
RESULT=""
SPLIT=no
while [ $# -gt 0 ]; do
case $1 in
--unix|-u)
PATHSEPT="\\;"
OUTPATHSEPT=":"
ARGS="$ARGS $1"
;;
--mixed|--windows|-m|-w)
PATHSEPT=":"
OUTPATHSEPT=";"
ARGS="$ARGS $1"
;;
--path|-p)
SPLIT=yes
;;
--*)
ARGS="$ARGS $1"
;;
*)
TMPPATH=$1
;;
esac
shift
done
if [ "$SPLIT" = "no" ]; then
cygpath $ARGS "$TMPPATH"
else
NF=`echo "$TMPPATH" | awk -F${PATHSEPT} '{ print NF }'`
i=1
while [ $i -le $NF ]; do
CMDLINE="echo \"$TMPPATH\" | awk -F${PATHSEPT} '{ print \$$i }'"
PATHITEM=`eval $CMDLINE`
if [ `echo $PATHITEM|wc -c` -lt 100 ]; then
PATHITEM=`cygpath $ARGS $PATHITEM`
fi
if [ "x$RESULT" = "x" ]; then
RESULT="$PATHITEM"
else
RESULT="${RESULT}${OUTPATHSEPT}${PATHITEM}"
fi
i=`expr $i + 1`
done
echo $RESULT
fi
}
{
ARGS=""
PATHSEPT=":"
RESULT=""
SPLIT=no
while [ $# -gt 0 ]; do
case $1 in
--unix|-u)
PATHSEPT="\\;"
OUTPATHSEPT=":"
ARGS="$ARGS $1"
;;
--mixed|--windows|-m|-w)
PATHSEPT=":"
OUTPATHSEPT=";"
ARGS="$ARGS $1"
;;
--path|-p)
SPLIT=yes
;;
--*)
ARGS="$ARGS $1"
;;
*)
TMPPATH=$1
;;
esac
shift
done
if [ "$SPLIT" = "no" ]; then
cygpath $ARGS "$TMPPATH"
else
NF=`echo "$TMPPATH" | awk -F${PATHSEPT} '{ print NF }'`
i=1
while [ $i -le $NF ]; do
CMDLINE="echo \"$TMPPATH\" | awk -F${PATHSEPT} '{ print \$$i }'"
PATHITEM=`eval $CMDLINE`
if [ `echo $PATHITEM|wc -c` -lt 100 ]; then
PATHITEM=`cygpath $ARGS $PATHITEM`
fi
if [ "x$RESULT" = "x" ]; then
RESULT="$PATHITEM"
else
RESULT="${RESULT}${OUTPATHSEPT}${PATHITEM}"
fi
i=`expr $i + 1`
done
echo $RESULT
fi
}
FOP 中文化
Use the special xsl to build fo.
(And the FOP has bug to handle FO file which language is zh_cn, So you may have to replace language="zh_cn" to language="zh")
(And the FOP has bug to handle FO file which language is zh_cn, So you may have to replace language="zh_cn" to language="zh")
Must have the Chinese font files and use org.apache.fop.fonts.apps.
TTFReader to build the font metrics-files. And build pdf with '-c userconfig.xml' option.
TTFReader to build the font metrics-files. And build pdf with '-c userconfig.xml' option.
增加中文字体
由 FOP TTFReader 生成的 matrics 文件
配置文件 fop/conf/userconfig.xml
在 <fonts></fonts> 之间增加
<font metrics-file="C:/Apps/fonts/simsun.xml"
embed-file="C:/Apps/fonts/simsun.ttc" kerning="yes">
<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>
<font metrics-file="C:/Apps/fonts/simhei.xml"
embed-file="C:/Apps//fonts/simhei.ttf" kerning="yes">
<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>
embed-file="C:/Apps/fonts/simsun.ttc" kerning="yes">
<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>
<font metrics-file="C:/Apps/fonts/simhei.xml"
embed-file="C:/Apps//fonts/simhei.ttf" kerning="yes">
<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>