Fixing bug in xmlclass with empty CDATA. Empty CDATA aren't present in xml tree and prompt error when trying to load empty ANY tag using CDATA
--- a/xmlclass/xmlclass.py Wed Nov 23 00:19:27 2011 +0100
+++ b/xmlclass/xmlclass.py Thu Nov 24 16:30:06 2011 +0100
@@ -1353,7 +1353,9 @@
elements = []
for element in classinfos["elements"]:
if element["type"] == ANY:
- elements.append(ComputeMultiplicity("#cdata-section |\w* ", element))
+ infos = element.copy()
+ infos["minOccurs"] = 0
+ elements.append(ComputeMultiplicity("#cdata-section |\w* ", infos))
elif element["type"] == CHOICE:
choices = []
for infos in element["choices"]:
@@ -1400,6 +1402,7 @@
structure_model = re.compile("(%s)$" % structure_pattern)
result = structure_model.match(children_structure)
if not result:
+ print structure_model.pattern, children_structure
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"):