Don't omit sequence on RNG generation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 13 Oct 2016 12:46:57 +0200
changeset 1783 c29eea525d9e
parent 1742 6493df257368
child 1784 a77fc051bb8a
Don't omit sequence on RNG generation Else we may end up in bad element ordering when some sequence is not generated, eg when iterating on children, if first element is a skipped sequence, its sibling elements will occur before its children, while they should not.
entities/profile_generation.py
--- a/entities/profile_generation.py	Thu Oct 13 14:26:14 2016 +0200
+++ b/entities/profile_generation.py	Thu Oct 13 12:46:57 2016 +0200
@@ -611,9 +611,8 @@
 
     def element_sequence(self, occ, profile_element, target_value, to_process, card_entity):
         parent_element = self._rng_element_parent(occ, card_entity, profile_element)
-        if parent_element.tag == '{http://relaxng.org/ns/structure/1.0}choice':
-            parent_element = self.element('rng:group', parent_element)  # XXX sequence
-        to_process[occ.target].append((target_value, parent_element))
+        target_element = self.element('rng:group', parent_element)  # XXX sequence
+        to_process[occ.target].append((target_value, target_element))
 
     def element_xmlattribute(self, occ, profile_element, target_value, to_process, card_entity):
         parent_element = self._rng_attribute_parent(occ, card_entity, profile_element)