Browse Source

----------------------------------------------------------------------

Modified Files:
 	XMLSchema.py -- If a schema needs to 'create' a schema instance
		itself it adds this schema to its import dictionary.

 ----------------------------------------------------------------------
main
Joshua Boverhof 21 years ago
parent
commit
b019fffbdd
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      XMLSchema.py

+ 12
- 6
XMLSchema.py View File

@@ -856,10 +856,10 @@ class XMLSchema(XMLSchemaComponent):
schema -- schema instance schema -- schema instance
_imported_schemas _imported_schemas
""" """
if not isinstance(schema, Schema):
if not isinstance(schema, XMLSchema):
raise TypeError, 'expecting a Schema instance' raise TypeError, 'expecting a Schema instance'
if schema.targetNamespace != self.targetNamespace: if schema.targetNamespace != self.targetNamespace:
self._imported_schemas[schema.targetNamespace]
self._imported_schemas[schema.targetNamespace] = schema
else: else:
raise SchemaError, 'import schema bad targetNamespace' raise SchemaError, 'import schema bad targetNamespace'


@@ -869,7 +869,7 @@ class XMLSchema(XMLSchemaComponent):
schema -- schema instance schema -- schema instance
_included_schemas _included_schemas
""" """
if not isinstance(schema, Schema):
if not isinstance(schema, XMLSchema):
raise TypeError, 'expecting a Schema instance' raise TypeError, 'expecting a Schema instance'
if not schema.targetNamespace or\ if not schema.targetNamespace or\
schema.targetNamespace == self.targetNamespace: schema.targetNamespace == self.targetNamespace:
@@ -986,13 +986,19 @@ class XMLSchema(XMLSchemaComponent):
elif component == 'import': elif component == 'import':
tp = self.__class__.Import(self) tp = self.__class__.Import(self)
tp.fromDom(node) tp.fromDom(node)
if tp.attributes['namespace']:
if tp.attributes['namespace'] == self.targetNamespace:
import_ns = tp.getAttribute('namespace')
if import_ns:
if import_ns == self.targetNamespace:
raise SchemaError,\ raise SchemaError,\
'import and schema have same targetNamespace' 'import and schema have same targetNamespace'
self.imports[tp.attributes['namespace']] = tp
self.imports[import_ns] = tp
else: else:
self.imports[self.__class__.empty_namespace] = tp self.imports[self.__class__.empty_namespace] = tp

if not self.getImportSchemas().has_key(import_ns) and\
tp.getAttribute('schemaLocation'):
self.addImportSchema(tp.getSchema())

elif component == 'redefine': elif component == 'redefine':
#print_debug('class %s, redefine skipped' %self.__class__, 5) #print_debug('class %s, redefine skipped' %self.__class__, 5)
pass pass


Loading…
Cancel
Save