Fixing bug in xmlclass with simple type elements containing #text node instead of cdata
authorlaurent
Wed, 14 Dec 2011 15:13:36 +0100
changeset 603 25c92309cdae
parent 602 7cadf0e2ae05
child 604 5b42b4401e6b
Fixing bug in xmlclass with simple type elements containing #text node instead of cdata
xmlclass/xmlclass.py
--- a/xmlclass/xmlclass.py	Mon Dec 12 00:38:24 2011 +0100
+++ b/xmlclass/xmlclass.py	Wed Dec 14 15:13:36 2011 +0100
@@ -1366,7 +1366,7 @@
                 choices.append(ComputeMultiplicity(structure, infos))
             elements.append(ComputeMultiplicity("|".join(choices), element))
         elif element["name"] == "content" and element["elmt_type"]["type"] == SIMPLETYPE:
-            elements.append("(?:#cdata-section )?")
+            elements.append("(?:#text |#cdata-section )?")
         else:
             elements.append(ComputeMultiplicity("%s " % element["name"], element))
     if classinfos.get("order", True) or len(elements) == 0:
@@ -1402,6 +1402,7 @@
                 structure_model = re.compile("(%s)$" % structure_pattern)
                 result = structure_model.match(children_structure)
                 if not result:
+                    print children_structure, structure_model.pattern
                     raise ValueError("Invalid structure for \"%s\" children!." % tree.nodeName)
         required_attributes = dict([(attr["name"], True) for attr in classinfos["attributes"] if attr["use"] == "required"])
         if classinfos.has_key("base"):