Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Z:\docbook\jars Z:\docbook\readme Z:\docbook\template Z:\docbook\xsl Z:\docbook\docbook.iss Z:\docbook\generate Z:\docbook\generate.bat Z:\docbook\hhc.exe Z:\docbook\make_zip.sh Z:\docbook\modpath.iss Z:\docbook\word2docbook Z:\docbook\word2docbook.bat git-svn-id: svn://servers.bphogan.com/docbook/trunk@675 d2f420bf-76e2-324b-a3e6-541d5c032d89
- Loading branch information
brianhogan
committed
Apr 4, 2008
1 parent
690b4e8
commit f96441b
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
class Docbook | ||
attr_accessor :input, :output, :root | ||
|
||
def initialize(options = {}) | ||
@root = File.dirname(__FILE__) | ||
@input = options[:input] | ||
@output = options[:output] | ||
@windows = PLATFORM.downcase.include?("win32") | ||
end | ||
|
||
|
||
def xml_config | ||
xml_parser_config = "-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl" | ||
xml_parser_config << " -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl" | ||
xml_parser_config << " -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration" | ||
xml_parser_config | ||
end | ||
|
||
def xml_cp | ||
saxon_cp = "#{self.root}/jars/xercesImpl-2.7.1.jar;" | ||
saxon_cp <<"#{self.root}/xsl/extensions/saxon65.jar;" | ||
saxon_cp <<"#{self.root}/jars/saxon.jar;" | ||
saxon_cp | ||
end | ||
|
||
|
||
# Generates the xml xslt processor command. | ||
# Pass in the input, output, and stylesheet | ||
def xml_cmd(input, output, stylesheet) | ||
|
||
cmd = "java -Xss512K -Xmx256m -cp \"#{xml_cp}\" #{xml_config} com.icl.saxon.StyleSheet -o \"#{output}\" \"#{input}\" #{stylesheet}" | ||
|
||
cmd.gsub!(";",":") unless @windows | ||
return cmd | ||
|
||
end | ||
|
||
def render | ||
xsl_path = "#{self.root}/xsl/roundtrip" | ||
|
||
cmd_1 = xml_cmd(self.input, "normalised.xml", xsl_path + "/wordml-normalise.xsl") | ||
cmd_2 = xml_cmd("normalised.xml", "sections.xml", xsl_path + "/wordml-sections.xsl") | ||
cmd_3 = xml_cmd("sections.xml", "blocks.xml", xsl_path + "/wordml-blocks.xsl") | ||
cmd_4 = xml_cmd("blocks.xml", self.output, xsl_path + "/wordml-final.xsl") | ||
|
||
`#{cmd_1}` | ||
`#{cmd_2}` | ||
`#{cmd_3}` | ||
`#{cmd_4}` | ||
end | ||
|
||
end | ||
|
||
infile = ARGV[0] | ||
outfile = ARGV[1] | ||
|
||
d = Docbook.new(:input => infile, :output=>outfile) | ||
|
||
d.render |