diff --git a/Utility.py b/Utility.py index 46860aa..84e42f6 100755 --- a/Utility.py +++ b/Utility.py @@ -50,6 +50,9 @@ class RecursionError(Exception): """Used to indicate a HTTP redirect recursion.""" pass +class ParseError(Exception): + """Used to indicate a XML parsing error.""" + class HTTPResponse: """Captures the information in an HTTP response message.""" @@ -574,8 +577,13 @@ class DOM: def loadFromURL(self, url): """Load an xml file from a URL and return a DOM document.""" file = urlopen(url) - try: result = self.loadDocument(file) - finally: file.close() + try: + result = self.loadDocument(file) + except Exception, ex: + file.close() + raise ParseError(('Failed to load document %s' %url,) + ex.args) + else: + file.close() return result diff --git a/XMLSchema.py b/XMLSchema.py index 8402c78..6377d50 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -1468,7 +1468,7 @@ class AttributeGroupDefinition(XMLSchemaComponent,\ self.annotation.fromDom(contents[indx]) elif component == 'attribute': if contents[indx].hasattr('name'): - content.append(AttributeDeclaration(self)) + content.append(LocalAttributeDeclaration(self)) elif contents[indx].hasattr('ref'): content.append(AttributeReference(self)) else: