| 1 |
# |
| 2 |
# Basic wrapper for saxon. |
| 3 |
# |
| 4 |
import os |
| 5 |
import logging |
| 6 |
import re |
| 7 |
from subprocess import call, Popen, PIPE |
| 8 |
|
| 9 |
class Saxon: |
| 10 |
def __init__(self): |
| 11 |
self.catalogs = os.getenv("SGML_CATALOG_FILES") |
| 12 |
self.use_catalogs = 1 |
| 13 |
self.log = logging.getLogger("dblatex") |
| 14 |
self.run_opts = [] |
| 15 |
|
| 16 |
def get_deplist(self): |
| 17 |
return ["saxon"] |
| 18 |
|
| 19 |
def run(self, xslfile, xmlfile, outfile, opts=None, params=None): |
| 20 |
cmd = ["saxon-xslt", "-o", os.path.basename(outfile)] + self.run_opts |
| 21 |
if opts: |
| 22 |
cmd += opts |
| 23 |
cmd += [xmlfile, xslfile] |
| 24 |
if params: |
| 25 |
for param, value in params.items(): |
| 26 |
cmd += ["%s=%s" % (param, "'%s'" % value)] |
| 27 |
self.system(cmd) |
| 28 |
|
| 29 |
def system(self, cmd): |
| 30 |
self.log.debug(" ".join(cmd)) |
| 31 |
rc = call(cmd) |
| 32 |
if rc != 0: |
| 33 |
raise ValueError("saxon failed") |
| 34 |
|
| 35 |
def _has_xincludestyle(self): |
| 36 |
return False |
| 37 |
|
| 38 |
|
| 39 |
class Xslt(Saxon): |
| 40 |
"Plugin Class to load" |