summaryrefslogtreecommitdiff
path: root/itstool.in
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2013-08-21 09:45:39 -0400
committerShaun McCance <shaunm@gnome.org>2013-08-21 09:45:39 -0400
commite4c6adab00c64141483b322d482a3819968b700e (patch)
treed8b8258dc6aaf0f1338c0c567fe328aec325abd0 /itstool.in
parent5040a328ba73ec3dd119f013b9a12a2fdc99a6b9 (diff)
parent34cc26b03424cd3ac72c041c8b576000ce2011d2 (diff)
downloaditstool-e4c6adab00c64141483b322d482a3819968b700e.tar.gz
Merge commit 'refs/merge-requests/4' of gitorious.org:itstool/itstool
Diffstat (limited to 'itstool.in')
-rwxr-xr-xitstool.in13
1 files changed, 10 insertions, 3 deletions
diff --git a/itstool.in b/itstool.in
index ed9d12f..db6627a 100755
--- a/itstool.in
+++ b/itstool.in
@@ -366,7 +366,7 @@ def fix_node_ns (node, nsdefs):
class Document (object):
- def __init__ (self, filename, messages):
+ def __init__ (self, filename, messages, load_dtd=False):
self._xml_err = ''
libxml2.registerErrorHandler(xml_error_catcher, self)
try:
@@ -375,6 +375,8 @@ class Document (object):
sys.stderr.write('Error: cannot open XML file %s\n' % filename)
sys.exit(1)
ctxt.lineNumbers(1)
+ if load_dtd:
+ ctxt.loadSubset(1)
ctxt.replaceEntities(1)
ctxt.parseDocument()
self._filename = filename
@@ -1112,6 +1114,11 @@ if __name__ == '__main__':
dest='strict',
default=False,
help='Exit with error when PO files contain broken XML')
+ options.add_option('-d', '--load-dtd',
+ action='store_true',
+ dest='load_dtd',
+ default=False,
+ help='Load external DTDs used by input XML')
options.add_option('-v', '--version',
action='store_true',
dest='version',
@@ -1126,7 +1133,7 @@ if __name__ == '__main__':
if opts.merge is None and opts.join is None:
messages = MessageList()
for filename in args[1:]:
- doc = Document(filename, messages)
+ doc = Document(filename, messages, opts.load_dtd)
doc.apply_its_rules()
if opts.itsfile is not None:
for itsfile in opts.itsfile:
@@ -1164,7 +1171,7 @@ if __name__ == '__main__':
sys.exit(1)
for filename in args[1:]:
messages = MessageList()
- doc = Document(filename, messages)
+ doc = Document(filename, messages, load_dtd=opts.load_dtd)
doc.apply_its_rules()
if opts.itsfile is not None:
for itsfile in opts.itsfile: