diff options
author | Shaun McCance <shaunm@gnome.org> | 2012-05-16 11:12:19 -0400 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2012-05-16 11:12:19 -0400 |
commit | 5c47aea87ecd67b69cc7596a61db0ff950e71063 (patch) | |
tree | fad4c81d7e08c68455a6382f7e91cb9a0e76a96e | |
parent | f53cb2b28fafaf6488f283020bc4de6c86f75c0a (diff) | |
download | itstool-5c47aea87ecd67b69cc7596a61db0ff950e71063.tar.gz |
Be much more strict (and correct) about the version attribute
-rw-r--r-- | its/docbook.its | 2 | ||||
-rw-r--r-- | its/its.its | 2 | ||||
-rw-r--r-- | its/mallard.its | 2 | ||||
-rw-r--r-- | its/ttml.its | 2 | ||||
-rw-r--r-- | its/xhtml.its | 2 | ||||
-rwxr-xr-x | itstool.in | 38 |
6 files changed, 41 insertions, 7 deletions
diff --git a/its/docbook.its b/its/docbook.its index 3b003dc..3c22c17 100644 --- a/its/docbook.its +++ b/its/docbook.its @@ -1,7 +1,7 @@ <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:itst="http://itstool.org/extensions/" - its:version="1.0"> + version="1.0"> <itst:match selector="/book"/> <itst:match selector="/article"/> diff --git a/its/its.its b/its/its.its index cf3ed81..b832add 100644 --- a/its/its.its +++ b/its/its.its @@ -1,5 +1,5 @@ <its:rules xmlns:its="http://www.w3.org/2005/11/its" - its:version="1.0"> + version="1.0"> <its:translateRule translate="no" selector="//its:locNote"/> </its:rules> diff --git a/its/mallard.its b/its/mallard.its index eaf31c3..ab5e725 100644 --- a/its/mallard.its +++ b/its/mallard.its @@ -2,7 +2,7 @@ xmlns:its="http://www.w3.org/2005/11/its" xmlns:itst="http://itstool.org/extensions/" xmlns:mal="http://projectmallard.org/1.0/" - its:version="1.0"> + version="1.0"> <itst:match selector="/mal:page"/> diff --git a/its/ttml.its b/its/ttml.its index 6530c72..72d544f 100644 --- a/its/ttml.its +++ b/its/ttml.its @@ -1,6 +1,6 @@ <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:tt="http://www.w3.org/ns/ttml" - its:version="1.0"> + version="1.0"> <its:withinTextRule withinText="yes" selector="//tt:p//*"/> </its:rules> diff --git a/its/xhtml.its b/its/xhtml.its index 7ecd60e..a3b192c 100644 --- a/its/xhtml.its +++ b/its/xhtml.its @@ -2,7 +2,7 @@ xmlns:its="http://www.w3.org/2005/11/its" xmlns:itst="http://itstool.org/extensions/" xmlns:html="http://www.w3.org/1999/xhtml" - its:version="1.0"> + version="1.0"> <itst:match selector="/html:html"/> @@ -386,8 +386,32 @@ class Document (object): hctxt = libxml2.createFileParserCtxt(href) hctxt.replaceEntities(1) hctxt.parseDocument() - self._localrules.append(hctxt.doc().getRootElement()) - self._localrules.append(child) + root = hctxt.doc().getRootElement() + version = None + if root.hasNsProp('version', None): + version = root.nsProp('version', None) + else: + sys.stderr.write('Warning: ITS file %s missing version attribute\n' % + os.path.basename(href)) + if version is not None and version != '1.0': + sys.stderr.write('Warning: Skipping ITS file %s with unknown version %s\n' % + (os.path.basename(href), root.nsProp('version', None))) + else: + self._localrules.append(root) + version = None + if child.hasNsProp('version', None): + version = child.nsProp('version', None) + else: + root = child.doc.getRootElement() + if root.hasNsProp('version', NS_ITS): + version = root.nsProp('version', NS_ITS) + else: + sys.stderr.write('Warning: Local ITS rules missing version attribute\n') + if version is not None and version != '1.0': + sys.stderr.write('Warning: Skipping local ITS rules with unknown version %s\n' % + version) + else: + self._localrules.append(child) pre_process(child) pre_process(self._doc) try: @@ -555,6 +579,16 @@ class Document (object): root = doc.getRootElement() if not xml_is_ns_name(root, NS_ITS, 'rules'): return + version = None + if root.hasNsProp('version', None): + version = root.nsProp('version', None) + else: + sys.stderr.write('Warning: ITS file %s missing version attribute\n' % + os.path.basename(filename)) + if version is not None and version != '1.0': + sys.stderr.write('Warning: Skipping ITS file %s with unknown version %s\n' % + (os.path.basename(filename), root.nsProp('version', None))) + return matched = True for match in xml_child_iter(root): if xml_is_ns_name(match, NS_ITST, 'match'): |