@@ -340,7 +340,7 @@ def visit_element(self, node, parent):
340340 else :
341341 qname = etree .QName (node .get ('name' ).strip ())
342342
343- children = node . getchildren ( )
343+ children = list ( node )
344344 xsd_type = None
345345 if children :
346346 value = None
@@ -422,7 +422,7 @@ def visit_attribute(self, node, parent):
422422 else :
423423 name = etree .QName (node .get ('name' ))
424424
425- annotation , items = self ._pop_annotation (node . getchildren ( ))
425+ annotation , items = self ._pop_annotation (list ( node ))
426426 if items :
427427 xsd_type = self .visit_simple_type (items [0 ], node )
428428 else :
@@ -472,7 +472,7 @@ def visit_simple_type(self, node, parent):
472472 base_type = '{http://www.w3.org/2001/XMLSchema}string'
473473 qname = as_qname (name , node .nsmap , self .document ._target_namespace )
474474
475- annotation , items = self ._pop_annotation (node . getchildren ( ))
475+ annotation , items = self ._pop_annotation (list ( node ))
476476 child = items [0 ]
477477 if child .tag == tags .restriction :
478478 base_type = self .visit_restriction_simple_type (child , node )
@@ -535,7 +535,7 @@ def visit_complex_type(self, node, parent):
535535 xsd_type = None
536536
537537 # Process content
538- annotation , children = self ._pop_annotation (node . getchildren ( ))
538+ annotation , children = self ._pop_annotation (list ( node ))
539539 first_tag = children [0 ].tag if children else None
540540
541541 if first_tag == tags .simpleContent :
@@ -586,8 +586,8 @@ def visit_complex_content(self, node, parent):
586586 :type parent: lxml.etree._Element
587587
588588 """
589-
590- child = node . getchildren () [- 1 ]
589+ children = list ( node )
590+ child = children [- 1 ]
591591
592592 if child .tag == tags .restriction :
593593 base , element , attributes = self .visit_restriction_complex_content (
@@ -626,7 +626,8 @@ def visit_simple_content(self, node, parent):
626626
627627 """
628628
629- child = node .getchildren ()[- 1 ]
629+ children = list (node )
630+ child = children [- 1 ]
630631
631632 if child .tag == tags .restriction :
632633 return self .visit_restriction_simple_content (child , node )
@@ -659,7 +660,7 @@ def visit_restriction_simple_type(self, node, parent):
659660 if base_name :
660661 return self ._get_type (base_name )
661662
662- annotation , children = self ._pop_annotation (node . getchildren ( ))
663+ annotation , children = self ._pop_annotation (list ( node ))
663664 if children [0 ].tag == tags .simpleType :
664665 return self .visit_simple_type (children [0 ], node )
665666
@@ -710,7 +711,7 @@ def visit_restriction_complex_content(self, node, parent):
710711 """
711712 base_name = qname_attr (node , 'base' )
712713 base_type = self ._get_type (base_name )
713- annotation , children = self ._pop_annotation (node . getchildren ( ))
714+ annotation , children = self ._pop_annotation (list ( node ))
714715
715716 element = None
716717 attributes = []
@@ -745,7 +746,7 @@ def visit_extension_complex_content(self, node, parent):
745746 """
746747 base_name = qname_attr (node , 'base' )
747748 base_type = self ._get_type (base_name )
748- annotation , children = self ._pop_annotation (node . getchildren ( ))
749+ annotation , children = self ._pop_annotation (list ( node ))
749750
750751 element = None
751752 attributes = []
@@ -773,7 +774,7 @@ def visit_extension_simple_content(self, node, parent):
773774 """
774775 base_name = qname_attr (node , 'base' )
775776 base_type = self ._get_type (base_name )
776- annotation , children = self ._pop_annotation (node . getchildren ( ))
777+ annotation , children = self ._pop_annotation (list ( node ))
777778 attributes = self ._process_attributes (node , children )
778779
779780 return base_type , attributes
@@ -853,8 +854,8 @@ def visit_sequence(self, node, parent):
853854 result = xsd_elements .Sequence (
854855 min_occurs = min_occurs , max_occurs = max_occurs )
855856
856- annotation , items = self ._pop_annotation (node . getchildren ( ))
857- for child in items :
857+ annotation , children = self ._pop_annotation (list ( node ))
858+ for child in children :
858859 if child .tag not in sub_types :
859860 raise self ._create_error (
860861 "Unexpected element %s in xsd:sequence" % child .tag , child )
@@ -892,8 +893,8 @@ def visit_all(self, node, parent):
892893 ]
893894 result = xsd_elements .All ()
894895
895- annotation , items = self ._pop_annotation (node . getchildren ( ))
896- for child in items :
896+ annotation , children = self ._pop_annotation (list ( node ))
897+ for child in children :
897898 assert child .tag in sub_types , child
898899 item = self .process (child , node )
899900 result .append (item )
@@ -934,7 +935,7 @@ def visit_group(self, node, parent):
934935 qname = qname_attr (node , 'name' , self .document ._target_namespace )
935936
936937 # There should be only max nodes, first node (annotation) is irrelevant
937- annotation , children = self ._pop_annotation (node . getchildren ( ))
938+ annotation , children = self ._pop_annotation (list ( node ))
938939 child = children [0 ]
939940
940941 item = self .process (child , parent )
@@ -969,7 +970,7 @@ def visit_list(self, node, parent):
969970 if item_type :
970971 sub_type = self ._get_type (item_type .text )
971972 else :
972- subnodes = node . getchildren ( )
973+ subnodes = list ( node )
973974 child = subnodes [- 1 ] # skip annotation
974975 sub_type = self .visit_simple_type (child , node )
975976 return xsd_types .ListType (sub_type )
@@ -988,8 +989,7 @@ def visit_choice(self, node, parent):
988989 """
989990 min_occurs , max_occurs = _process_occurs_attrs (node )
990991
991- children = node .getchildren ()
992- annotation , children = self ._pop_annotation (children )
992+ annotation , children = self ._pop_annotation (list (node ))
993993
994994 choices = []
995995 for child in children :
@@ -1025,7 +1025,7 @@ def visit_union(self, node, parent):
10251025 xsd_type = self ._get_type (qname )
10261026 types .append (xsd_type )
10271027 else :
1028- annotation , types = self ._pop_annotation (node . getchildren ( ))
1028+ annotation , types = self ._pop_annotation (list ( node ))
10291029 types = [self .visit_simple_type (t , node ) for t in types ]
10301030 return xsd_types .UnionType (types )
10311031
@@ -1076,7 +1076,7 @@ def visit_attribute_group(self, node, parent):
10761076 return ref
10771077
10781078 qname = qname_attr (node , 'name' , self .document ._target_namespace )
1079- annotation , children = self ._pop_annotation (node . getchildren ( ))
1079+ annotation , children = self ._pop_annotation (list ( node ))
10801080
10811081 attributes = self ._process_attributes (node , children )
10821082 attribute_group = xsd_elements .AttributeGroup (qname , attributes )
0 commit comments