@@ -850,7 +850,10 @@ def visit_sequence(self, node, parent):
850
850
851
851
annotation , items = self ._pop_annotation (node .getchildren ())
852
852
for child in items :
853
- assert child .tag in sub_types , child
853
+ if child .tag not in sub_types :
854
+ raise self ._create_error (
855
+ "Unexpected element %s in xsd:sequence" % child .tag , child )
856
+
854
857
item = self .process (child , node )
855
858
assert item is not None
856
859
result .append (item )
@@ -1166,12 +1169,16 @@ def _process_attributes(self, node, items):
1166
1169
attribute = self .process (child , node )
1167
1170
attributes .append (attribute )
1168
1171
else :
1169
- raise XMLParseError (
1170
- "Unexpected tag `%s`" % (child .tag ),
1171
- filename = self .document ._location ,
1172
- sourceline = node .sourceline )
1172
+ raise self ._create_error (
1173
+ "Unexpected tag `%s`" % (child .tag ), node )
1173
1174
return attributes
1174
1175
1176
+ def _create_error (self , message , node ):
1177
+ return XMLParseError (
1178
+ message ,
1179
+ filename = self .document ._location ,
1180
+ sourceline = node .sourceline )
1181
+
1175
1182
visitors = {
1176
1183
tags .any : visit_any ,
1177
1184
tags .element : visit_element ,
0 commit comments