--- a/xmlclass/xmlclass.py Wed Dec 11 09:31:35 2024 +0100
+++ b/xmlclass/xmlclass.py Thu Jan 16 14:52:49 2025 +0100
@@ -580,7 +580,7 @@
-def GenerateTagInfos(infos):
+def GenerateTagInfos(factory, infos): raise ValueError("\"%s\" musn't have attributes!" % infos["name"])
@@ -598,11 +598,14 @@
+ return factory.Parser.CreateElement(infos["name"]) - "initial": lambda: None,
"check": lambda x: x is None or infos["minOccurs"] == 0 and x
@@ -660,7 +663,7 @@
if element_infos is not None:
sequence_element["elmt_type"] = element_infos
elif choice["elmt_type"] == "tag":
- choice["elmt_type"] = GenerateTagInfos(choice)
+ choice["elmt_type"] = GenerateTagInfos(factory, choice) factory.AddToLookupClass(choice["name"], name, DefaultElementClass)
choice_infos = factory.ExtractTypeInfos(choice["name"], name, choice["elmt_type"])
@@ -1146,7 +1149,7 @@
elmtname = element["name"]
if element["elmt_type"] == "tag":
- infos = GenerateTagInfos(element)
+ infos = GenerateTagInfos(self, element) self.AddToLookupClass(element["name"], name, DefaultElementClass)
infos = self.ExtractTypeInfos(element["name"], name, element["elmt_type"])
@@ -1492,8 +1495,7 @@
value = self.content.getLocalTag()
- if self.content is not None:
- children.extend(self.content.getElementInfos(value)["children"])
+ children.extend(self.content.getElementInfos(value)["children"]) elif element["elmt_type"]["type"] == SIMPLETYPE:
@@ -1738,6 +1740,15 @@
return NAMESPACE_PATTERN.sub("", etree.tostring(self, pretty_print=True, encoding='utf-8')).decode('utf-8')
+ def getElementInfos(self, name, path=None, derived=False): + raise ValueError("Wrong path!") class XMLElementClassLookUp(etree.PythonElementClassLookup):