티스토리 뷰
docbkx-tools는 편리한 대신, xslt와 fop의 세밀한 옵션을 조절할 수 없다. 그래서 좀 더 삽질을 해봤다.
1. maven-dependency-plugin의 unpack-dependencies 골을 실행하여 docbook 스타일 시트와 카탈로그를 작업 디렉토리에 풀어 놓자. 예제에서는 generated-resources 페이즈에 net.sf.docbook:docbook-xsl 아티팩트를 target/generated-resources 폴더 아래에 풀어 놓는다(말이 참 어려운데... 가만히 들여다 보면 별거 아니다):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-shared-resources</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
<includeGroupIds>net.sf.docbook</includeGroupIds>
<includeArtifactIds>docbook-xsl</includeArtifactIds>
<includeClassifiers>resources</includeClassifiers>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-shared-resources</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
<includeGroupIds>net.sf.docbook</includeGroupIds>
<includeArtifactIds>docbook-xsl</includeArtifactIds>
<includeClassifiers>resources</includeClassifiers>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
2. xml-maven-plugin의 transform 골을 실행하여, 앞에서 풀어놓은 docbook 스타일 시트와 카탈로그들을 사용하여 xslt(여기서는 xalan을 사용했지만 saxon등 다른 xslt를 사용해도 된다)를 실행하여 fo 파일을 만든다. 예제에서는 generated-resources 페이즈에 src/docbook 디렉토리 아래에 manual.xml을 처리하여 처리하여 manual.fo인 파일을 만든다(parameters 요소를 사용하여 XSLT 파라메터를 지정할 수 있다):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
<!-- linked with generate-resources phase -->
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<catalogs>
<catalog>${project.build.directory}/generated-resources/docbook/catalog.xml</catalog>
</catalogs>
<transformationSets>
<transformationSet>
<dir>src/docbook/</dir>
<includes>
<include>manual.xml</include>
</includes>
<stylesheet>${project.build.directory}/generated-resources/docbook/fo/docbook.xsl</stylesheet>
<fileMappers>
<fileMapper
<goals>
<goal>transform</goal>
</goals>
<!-- linked with generate-resources phase -->
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<catalogs>
<catalog>${project.build.directory}/generated-resources/docbook/catalog.xml</catalog>
</catalogs>
<transformationSets>
<transformationSet>
<dir>src/docbook/</dir>
<includes>
<include>manual.xml</include>
</includes>
<stylesheet>${project.build.directory}/generated-resources/docbook/fo/docbook.xsl</stylesheet>
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.fo</targetExtension>
</fileMapper>
</fileMappers>
<outputDir>${project.build.directory}/</outputDir>
<!-- see http://docbook.sourceforge.net/release/xsl/current/doc/fo/ -->
<parameters>
<parameter>
<name>body.font.family</name>
<value>UnBatang</value>
</parameter>
<parameter>
<name>sans.font.family</name>
<value>UnDotum</value>
</parameter>
<parameter>
<name>title.font.family</name>
<value>hline</value>
</parameter>
<parameter>
<name>monospace.font.family</name>
<value>UnTaza</value>
</parameter>
</parameters>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl-xalan</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
<targetExtension>.fo</targetExtension>
</fileMapper>
</fileMappers>
<outputDir>${project.build.directory}/</outputDir>
<!-- see http://docbook.sourceforge.net/release/xsl/current/doc/fo/ -->
<parameters>
<parameter>
<name>body.font.family</name>
<value>UnBatang</value>
</parameter>
<parameter>
<name>sans.font.family</name>
<value>UnDotum</value>
</parameter>
<parameter>
<name>title.font.family</name>
<value>hline</value>
</parameter>
<parameter>
<name>monospace.font.family</name>
<value>UnTaza</value>
</parameter>
</parameters>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl-xalan</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
3. maven-antrun-plugin의 run 골을 실행하여, fop를 실행하여 앞에서 만들어진 fo 파일들을 처리하여 pdf를 만들어 낸다. 이 부분은 maven에서 ant 스크립트를 사용하는 전형적인 형태다. 예제에서는 pre-site 페이즈에 fop에 포함된 ant task를 사용하여 manual.fo를 처리하여 manual.pdf를 만든다(userconfig 속성를 통해 fop 설정 파일을 지정할 수 있다):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>0.95-1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<echo message="processing docbook..." />
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
</taskdef>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>0.95-1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<echo message="processing docbook..." />
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
</taskdef>
<fop
userconfig="src/docbook/fop-userconfig.xml"
format="application/pdf"
fofile="target/manual.fo"
outfile="target/manual.pdf" />
</tasks>
</configuration>
</plugin>
</configuration>
</plugin>
세삼 확인하게 되는 사실...
이런 류의 "절차적인" 삽질을 할때는 maven이 쥐약이라는 거...-,.-;;;
'hacking' 카테고리의 다른 글
세상은 넓고 오피스는 많다(1) - 데스크탑 오피스 (11) | 2009.12.01 |
---|---|
Google AppEngine(Python) 삽질기 - NetBeans편 (개정판#1) (0) | 2009.09.29 |
maven으로 docbook 다루기 - docbkx-tools (0) | 2009.08.27 |
개발자의, 개발자를 위한, 개발자에 의한 소프트웨어 - "통합 개발 환경(IDE)" (9) | 2009.06.14 |
Google AppEngine(Python) 삽질기 (3) | 2009.05.26 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 자전거
- ****
- Eclipse
- 장필순
- Ajax
- **
- JavaScript
- maven
- docker
- nodejs
- jQuery
- DeveloperWorks
- 해남
- CSS
- Prototype
- 독후감
- Java
- webapp
- 영화
- 노래
- 자바스크립트
- HTML5
- Dojo
- 여행
- 땅끝마을
- ***
- ***1/2
- web
- 책
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함