用maven-jdocbook-plugin简单配置docbook5.0环境

很多人都说docbook配置环境比较繁琐,今天看了一下docbook5的文档,5.0不再使用旧的SGML DTD,转而使用XML,感觉配置相对容易多了,网上有篇文章介绍5.0的编译环境,真的比较简单.不过我今天看了看jboss seam的文档构建过程,构建环境搭建真是简单的不能再简单了,jboss seam使用maven来发布docbook文档,用到了maven-jdocbook-plugin,我把jboss seam的构建提取出来,大家可以参考来方便构建自己的docbook.

创建一个最最简单的maven空项目,pom.xml内容如下:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
<modelVersion>4.0.0</modelVersion>
    
<groupId>org.kuuyee</groupId>
    
<artifactId>first-docbook</artifactId>
    
<packaging>jar</packaging>
    
<version>1.0-SNAPSHOT</version>
    
<name>first-docbook</name>

            
<build>
                
<plugins>
               
<!-- the docbook generation plugin for the user guide -->
                    
<plugin>
                        
<groupId>org.jboss.maven.plugins</groupId>
                        
<artifactId>maven-jdocbook-plugin</artifactId>
                        
<version>2.1.1</version>
                        
<extensions>true</extensions>
                        
<dependencies>
                            
<dependency>
                                
<groupId>org.jboss</groupId>
                                
<artifactId>jbossorg-docbook-xslt</artifactId>
                                
<version>1.1.0</version>
                            
</dependency>
                            
<dependency>
                                
<groupId>org.jboss</groupId>
                                
<artifactId>jbossorg-jdocbook-style</artifactId>
                                
<version>1.1.0</version>
                                
<type>jdocbook-style</type>
                            
</dependency>
                        
</dependencies>
                        
<executions>
                            
<execution>
                                
<id>tutorial_zh_CN</id>
                                
<phase>package</phase>
                                
<goals>
                                    
<goal>resources</goal>
                                    
<goal>generate</goal>
                                
</goals>
                                
<configuration>
                                    
<sourceDocumentName>master.xml</sourceDocumentName>
                                    
<sourceDirectory>${basedir}/src/main/docbook/zh_CN</sourceDirectory>
                                    
<imageResource>
                                        
<directory>${basedir}/src/main/docbook/images</directory>
                                    
</imageResource>
                                    
<cssResource>
                                        
<directory>${basedir}/src/main/docbook/css</directory>
                                    
</cssResource>
                                    
<targetDirectory>${basedir}/target/docbook/zh_CN</targetDirectory>

                                    
<formats>
                                        
<format>
                                            
<formatName>pdf</formatName>
                                            
<stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
                                            
<finalName>zh_CN.pdf</finalName>
                                        
</format>
                                        
<format>
                                            
<formatName>html</formatName>
                                            
<stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
                                            
<finalName>index.html</finalName>
                                        
</format>
                                        
<format>
                                            
<formatName>html_single</formatName>
                                            
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
                                            
<finalName>index.html</finalName>
                                        
</format>
                                    
</formats>
                                    
<options>
                                        
<xincludeSupported>true</xincludeSupported>
                                    
</options>
                                
</configuration>
                            
</execution>
                        
</executions>
                    
</plugin>
                
</plugins>
            
</build>
    
    
<!-- basic JBoss repository so that the common parent POM in jbosscache-support can be found -->
    
<repositories>
        
<repository>
            
<id>snapshots.jboss.org</id>
            
<url>http://snapshots.jboss.org/maven2</url>
        
</repository>
        
<repository>
            
<id>repository.jboss.org</id>
            
<url>http://repository.jboss.org/maven2</url>
        
</repository>
    
</repositories>
</project>

在src/main/docbook/zh_CN下新建两个xml文件master.xml,chap1.xml.这里用到了docbook的物理分割概念,就是把单个文档拆分文档为多个文件,这在文档比较巨大的时候很实用.
master.xml是文档主文件,内容如下:
<?xml version='1.0' encoding="utf-8"?>
<book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="zh-CN" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>光子的第一本Docbook书</title>
<xi:include href="chap1.xml"/>
</book>

chap1.xml是文档的第一章,内容如下:
<?xml version='1.0' encoding="utf-8"?>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="zh-CN"
  xmlns:xlink
="http://www.w3.org/1999/xlink" id="ch1" xmlns:xi="http://www.w3.org/2001/XInclude">

    
<title>光子的第一篇Docbook 5.0文档</title>
                  
  
<section>   
    
<title>第一章标题</title>
    
<para>
      这是光子的第一篇Docbook 5.0文档,我的BLOG
<link xlink:href='http://www.blogjava.net/kuuyee/'>光子CI之旅</link>。
    
</para>
  
</section>
</chapter>

ok,我们可以发布文档了,没错!就是这么简单,在项目根目录运行命令
mvn clean package

如果大家不明白可以下载附件源码看看!样式还是使用jboss的,不过可以自己修改xsl!
样例代码

贴张图看看生成的文档,呵呵!






posted on 2009-07-27 17:24 kuuyee 阅读(2753) 评论(2)  编辑  收藏 所属分类: Git/MavenJEE

评论

# re: 用maven-jdocbook-plugin简单配置docbook5.0环境 2010-02-26 09:42 王兴朝

你好!楼主,我想问一下你生成的pdf格式的文本文件中文有没有出现乱码呀(就是所有显示中文的地方全部用'#'代替了),html格式的文档没有出现乱码,跟你的贴图显示是一样的。控制台提示的信息为:
2010-2-26 9:23:10 org.apache.fop.hyphenation.Hyphenator getHyphenationTree
严重: Couldn't find hyphenation pattern en
希望楼主能帮忙解决一下,谢谢啦!  回复  更多评论   

# re: 用maven-jdocbook-plugin简单配置docbook5.0环境 2011-06-16 21:38 stliu

hi,

i'm the developer of maven-jdocbook-plugin, and I do have plan to add docbook 5.0 support, are you interested in helping on it :) ?

btw, the jdocbook plugin has been split into three projects:
jdocbook-core (https://github.com/sebersole/jdocbook-core)
jdocbook-maven-plugin (hosted in jboss svn)
jdocbook-gradle-plugin (https://github.com/gradle/gradle-jdocbook)

anyway, seems you're very interested in jboss projects, my email is stliu@hibernate.org, i also work on hibernate project.
thanks
  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

统计

随笔分类(139)

Linux内核

搜索

积分与排名

最新评论

阅读排行榜