Juan Hernandez has uploaded a new change for review. Change subject: codegen: Only top level elements in root class map ......................................................................
codegen: Only top level elements in root class map Currently we generate a dictionary that contains the relationship between XML element names and Python class names. This is required because the XML to Python conversion needs to know what is the class that corresponds to the root element of parsed XML documents. To generate this dictionary we search the XML schema for element definitions, and we take the type name as Python class name. For example, if we find the following element definition: <xs:element name="data_center" type="DataCenter"/> We create the following entry in the dictionary: "data_center": DataCenter We scan the XML schema recursively, and thus we include in this dictionary entries that correspond to element definitions that will never appear as root elements in XML documents. For example, for this XML schema definition: <xs:complexType name="OperatingSystem"> <xs:sequence> <xs:element name="boot" type="Boot" .../> ... </xs:sequence> ... </xs:complexType> We add the following entry in the dictionary: "boot": Boot In general this is harmless, as the entry will just never be used. But there is a real problem if the same XML element name is used twice with different types. This actually happens with the recently introduced "GuestNicsConfiguration" type, which is used to define a "nics" element inside the "Initialization" type: <xs:complexType name="Initialization"> <xs:sequence> ... <xs:element name="nics" type="GuestNicsConfiguration" .../> ... </xs:sequence> </xs:complexType> This has a conflict with the already existing top level "nics" element: <xs:element name="nics" type="Nics"/> To avoid this kind of conflict this patch changes the code generator so that it will take into account only the top level XML element definitions, as those are the only ones that can appear as root elements in XML documents valid according to the XML schema definition. Change-Id: Ifcdefe71f3d15ab0da841f35b4b94916d19d950d Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M src/codegen/xsd/genparams.py 1 file changed, 1 insertion(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk refs/changes/64/23964/1 diff --git a/src/codegen/xsd/genparams.py b/src/codegen/xsd/genparams.py index f0b47cd..995339e 100755 --- a/src/codegen/xsd/genparams.py +++ b/src/codegen/xsd/genparams.py @@ -592,9 +592,7 @@ elif key: elementDict[key] = elementNode.getAttribute("type") children = elementNode.childNodes - if children: - self.getElemetFromTree(children, elementDict, - rootClass, exclude) + def getSimpleTypeFromTree(self, elements, typeList): for elementNode in elements: if elementNode.nodeName == "xs:simpleType": -- To view, visit http://gerrit.ovirt.org/23964 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifcdefe71f3d15ab0da841f35b4b94916d19d950d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-sdk Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches