Modified Files:
Utility.py -- catch any exceptions thrown when a DOM is loaded up,
throw a ParseError with old ex.args and inform which file
caused the problem.
XMLSchema.py -- For attributeGroup incorrectly adding global
attribute declarations, but these are declared locally.
----------------------------------------------------------------------
main
| @@ -50,6 +50,9 @@ class RecursionError(Exception): | |||||
| """Used to indicate a HTTP redirect recursion.""" | """Used to indicate a HTTP redirect recursion.""" | ||||
| pass | pass | ||||
| class ParseError(Exception): | |||||
| """Used to indicate a XML parsing error.""" | |||||
| class HTTPResponse: | class HTTPResponse: | ||||
| """Captures the information in an HTTP response message.""" | """Captures the information in an HTTP response message.""" | ||||
| @@ -574,8 +577,13 @@ class DOM: | |||||
| def loadFromURL(self, url): | def loadFromURL(self, url): | ||||
| """Load an xml file from a URL and return a DOM document.""" | """Load an xml file from a URL and return a DOM document.""" | ||||
| file = urlopen(url) | 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 | return result | ||||
| @@ -1468,7 +1468,7 @@ class AttributeGroupDefinition(XMLSchemaComponent,\ | |||||
| self.annotation.fromDom(contents[indx]) | self.annotation.fromDom(contents[indx]) | ||||
| elif component == 'attribute': | elif component == 'attribute': | ||||
| if contents[indx].hasattr('name'): | if contents[indx].hasattr('name'): | ||||
| content.append(AttributeDeclaration(self)) | |||||
| content.append(LocalAttributeDeclaration(self)) | |||||
| elif contents[indx].hasattr('ref'): | elif contents[indx].hasattr('ref'): | ||||
| content.append(AttributeReference(self)) | content.append(AttributeReference(self)) | ||||
| else: | else: | ||||