From dde5a9ac006ab839b67e711e27977fbf074dc04e Mon Sep 17 00:00:00 2001 From: Shaun McCance Date: Sun, 27 Oct 2013 21:02:46 -0400 Subject: Add support for its:param --- itstool.in | 12 +++++++++++- tests/ITS-2.0-Testsuite/run_tests.sh | 16 +--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/itstool.in b/itstool.in index 4d2d605..bbf2e85 100755 --- a/itstool.in +++ b/itstool.in @@ -517,6 +517,13 @@ class Document (object): if self._xml_err: raise libxml2.parserError(self._xml_err) + def register_its_params(self, xpath, rules): + for child in xml_child_iter(rules): + if xml_is_ns_name(child, NS_ITS, 'param'): + name = child.nsProp('name', None) + value = child.getContent() + xpath.xpathRegisterVariable(name, None, value) + def apply_its_rule(self, rule, xpath): if rule.type != 'element': return @@ -746,6 +753,7 @@ class Document (object): xpath.xpathRegisterNs(nsdef.name, nsdef.content) nsdef = nsdef.next par = par.parent + self.register_its_params(xpath, root) self.apply_its_rule(rule, xpath) def apply_local_its_rules (self): @@ -760,12 +768,14 @@ class Document (object): nsdef = nsdef.next xpath = self._doc.xpathNewContext() reg_ns(xpath, rules) + self.register_its_params(xpath, rules) for rule in xml_child_iter(rules): if rule.type != 'element': continue if rule.nsDefs() is not None: - rule_xpath = self._doc.xpathNewContent() + rule_xpath = self._doc.xpathNewContext() reg_ns(rule_xpath, rule) + self.register_its_params(rule_xpath, rules) else: rule_xpath = xpath self.apply_its_rule(rule, rule_xpath) diff --git a/tests/ITS-2.0-Testsuite/run_tests.sh b/tests/ITS-2.0-Testsuite/run_tests.sh index f57ef00..7ee5d60 100755 --- a/tests/ITS-2.0-Testsuite/run_tests.sh +++ b/tests/ITS-2.0-Testsuite/run_tests.sh @@ -9,28 +9,14 @@ localizationnote/locnote/locNote preservespace/preservespace/preserveSpace translate/translate/translate " - exclude=" -externalresource4xml -externalresource5xml -idvalue4xml -idvalue5xml -locale7xml -locnote10xml -locnote11xml -preservespace5xml -preservespace6xml -translate9xml -translate10xml -withintext5xml -withintext6xml - locale1xml locale2xml locale3xml locale4xml locale5xml locale6xml +locale7xml locale8xml " -- cgit v1.2.1