From 12310fb9094e364283c0751a2762a9e5b38961ed Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Wed, 26 Oct 2005 18:22:15 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: XMLSchema.py -- fixed bug with xsd:import w/o schemaLocation. This bug may have been introduced with recursive import fix. ---------------------------------------------------------------------- --- XMLSchema.py | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/XMLSchema.py b/XMLSchema.py index b13c77c..4b8f582 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -1162,7 +1162,17 @@ class XMLSchema(XMLSchemaComponent): if schema is None: schema = XMLSchema() slocd[import_ns] = schema - tp.loadSchema(schema) + try: + tp.loadSchema(schema) + except SchemaError: + # Dependency declaration, hopefully implementation + # is aware of this namespace (eg. SOAP,WSDL,?) + warnings.warn(\ + ', %s'\ + %(import_ns, 'failed to load schema instance') + ) + del slocd[import_ns] + continue else: tp._schema = schema @@ -1211,38 +1221,6 @@ class XMLSchema(XMLSchemaComponent): else: break -# slocd = SchemaReader.namespaceToSchema -# -# print "XMLSchema(%d): %s" %(id(self), self.targetNamespace) -# -# for node in imports: -# tp = self.__class__.Import(self) -# tp.fromDom(node) -# -# import_ns = tp.getAttribute('namespace') or \ -# self.__class__.empty_namespace -# -# print "" %import_ns -# -# schema = slocd.get(import_ns) -# if schema is None: -# schema = XMLSchema() -# slocd[import_ns] = schema -# tp.loadSchema(schema) -# else: -# tp._schema = schema -# -# if self.getImportSchemas().has_key(import_ns): -# warnings.warn(\ -# 'Detected multiple imports of the namespace "%s",'+ -# 'may cause problems if they have different schemaLocations.' %import_ns -# ) -# raise RuntimeError, 'hi' -# -# self.addImportSchema(schema) -# self.imports[import_ns] = tp - - class Import(XMLSchemaComponent): """ parent: @@ -1310,6 +1288,9 @@ class XMLSchema(XMLSchemaComponent): reader._imports = self._parent().getImportSchemas() reader._includes = self._parent().getIncludeSchemas() self._schema = schema + + if not self.attributes.has_key('schemaLocation'): + raise SchemaError, 'no schemaLocation' reader.loadFromURL(self.attributes.get('schemaLocation'), schema)