--- a/xmlclass/xmlclass.py Thu Jan 09 17:11:18 2025 +0100
+++ b/xmlclass/xmlclass.py Thu Jan 16 14:52:49 2025 +0100
@@ -575,7 +575,7 @@
-def GenerateTagInfos(infos):
+def GenerateTagInfos(factory, infos): raise ValueError("\"%s\" musn't have attributes!" % infos["name"])
@@ -593,15 +593,14 @@
- p = etree.Element(infos["name"])
+ return factory.Parser.CreateElement(infos["name"])
"check": lambda x: x is None or infos["minOccurs"] == 0 and x
@@ -659,7 +658,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"])
@@ -1147,7 +1146,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"])
@@ -1489,8 +1488,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:
@@ -1736,7 +1734,14 @@
return NAMESPACE_PATTERN.sub("", etree.tostring(self, encoding='unicode'))
def getElementInfos(self, name, path=None, derived=False):
- return {"name": name, "type": TAG, "value": None, "use": None, "children": []}
+ raise ValueError("Simple element "+name+" accepts no path: "+path) class XMLElementClassLookUp(etree.PythonElementClassLookup):