--- a/xmlclass/xmlclass.py Fri Dec 09 11:26:10 2011 +0100
+++ b/xmlclass/xmlclass.py Mon Dec 12 00:25:18 2011 +0100
@@ -534,7 +534,7 @@
def GenerateAnyInfos(infos):
def ExtractAny(tree):
- if tree.nodeName == "#cdata-section":
+ if tree.nodeName in ["#text", "#cdata-section"]:
return tree.data.encode("utf-8")
else:
return tree
@@ -1355,7 +1355,7 @@
if element["type"] == ANY:
infos = element.copy()
infos["minOccurs"] = 0
- elements.append(ComputeMultiplicity("#cdata-section |\w* ", infos))
+ elements.append(ComputeMultiplicity("#text |#cdata-section |\w* ", infos))
elif element["type"] == CHOICE:
choices = []
for infos in element["choices"]:
@@ -1395,7 +1395,7 @@
if not derived:
children_structure = ""
for node in tree.childNodes:
- if node.nodeName not in ["#comment", "#text"]:
+ if not (node.nodeName == "#text" and node.data.strip() == "") and node.nodeName != "#comment":
children_structure += "%s " % node.nodeName
structure_pattern = self.getStructure()
if structure_pattern != "":
@@ -1419,7 +1419,7 @@
first = {}
for node in tree.childNodes:
name = node.nodeName
- if name in ["#text", "#comment"]:
+ if name == "#text" and node.data.strip() == "" or name == "#comment":
continue
elif elements.has_key(name):
elements[name]["elmt_type"] = FindTypeInfos(factory, elements[name]["elmt_type"])
@@ -1441,7 +1441,7 @@
else:
object.__setattr__(self, "text", elements["text"]["elmt_type"]["extract"](node))
elif elements.has_key("content"):
- if name == "#cdata-section":
+ if name in ["#cdata-section", "#text"]:
if elements["content"]["elmt_type"]["type"] == SIMPLETYPE:
object.__setattr__(self, "content", elements["content"]["elmt_type"]["extract"](node.data, False))
else: