[profile gen] Use xsd:NCName instead of xsd:IDREF in Relax NG export
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 05 Jan 2017 16:19:28 +0100
changeset 2224 c0d56eed71cd
parent 2223 f0cdce099e45
child 2225 f905983dfc5e
[profile gen] Use xsd:NCName instead of xsd:IDREF in Relax NG export because the later may only be used inside an attribute in Relax NG, while in SEDA we want to use it as tag content. This should not be problem if the profile is also checked against the SEDA 2 XSD. Closes #16687696
entities/profile_generation.py
test/test_profile_generation.py
--- a/entities/profile_generation.py	Fri Jan 06 12:35:08 2017 +0100
+++ b/entities/profile_generation.py	Thu Jan 05 16:19:28 2017 +0100
@@ -696,7 +696,7 @@
         if fixed_value is not None:
             if hasattr(value, 'id'):
                 profile_element.attrib[self.qname('a:defaultValue')] = fixed_value
-                self.element('rng:data', profile_element, {'type': 'IDREF'})
+                self.element('rng:data', profile_element, {'type': 'NCName'})
             else:
                 if (len(profile_element)
                         and profile_element[-1].tag == '{http://relaxng.org/ns/structure/1.0}data'):
--- a/test/test_profile_generation.py	Fri Jan 06 12:35:08 2017 +0100
+++ b/test/test_profile_generation.py	Thu Jan 05 16:19:28 2017 +0100
@@ -670,7 +670,7 @@
         references = self.xpath(root, '//rng:element[@a:defaultValue="bdo1"]')
         self.assertEqual(len(references), 1)
         self.assertEqual(references[0].attrib['name'], 'DataObjectReferenceId')
-        self.assertEqual(references[0][0].attrib['type'], 'IDREF')
+        self.assertEqual(references[0][0].attrib['type'], 'NCName')
         # ensure optional id are properly reinjected
         references = self.xpath(root,
                                 '//rng:element[@name="Keyword"]/rng:optional'