diff --git a/WSDLTools.py b/WSDLTools.py index 3fefb9e..f7a15e3 100755 --- a/WSDLTools.py +++ b/WSDLTools.py @@ -464,25 +464,25 @@ class Message(Element): if elemref is not None: part.element = ParseTypeRef(elemref, element) - def getElementDeclaration(self): - """Return the XMLSchema.ElementDeclaration instance or None""" - element = None - if self.element: - nsuri,name = self.element - wsdl = self.getWSDL() - if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].elements.has_key(name): - element = wsdl.types[nsuri].elements[name] - return element - - def getTypeDefinition(self): - """Return the XMLSchema.TypeDefinition instance or None""" - type = None - if self.type: - nsuri,name = self.type - wsdl = self.getWSDL() - if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].types.has_key(name): - type = wsdl.types[nsuri].types[name] - return type +# def getElementDeclaration(self): +# """Return the XMLSchema.ElementDeclaration instance or None""" +# element = None +# if self.element: +# nsuri,name = self.element +# wsdl = self.getWSDL() +# if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].elements.has_key(name): +# element = wsdl.types[nsuri].elements[name] +# return element +# +# def getTypeDefinition(self): +# """Return the XMLSchema.TypeDefinition instance or None""" +# type = None +# if self.type: +# nsuri,name = self.type +# wsdl = self.getWSDL() +# if wsdl.types.has_key(nsuri) and wsdl.types[nsuri].types.has_key(name): +# type = wsdl.types[nsuri].types[name] +# return type # def getWSDL(self): # """Return the WSDL object that contains this Message Part.""" diff --git a/XMLSchema.py b/XMLSchema.py index e7a33db..6e299c1 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -739,9 +739,16 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): raise SchemaError,\ 'class instance %s, missing required attribute %s'\ %(self.__class__, a) - for a in self.attributes.keys(): - if (a not in (XMLSchemaComponent.xmlns, XMLNS.XML)) and\ - (a not in self.__class__.attributes.keys()) and not\ + for a,v in self.attributes.items(): + # attribute #other, ie. not in empty namespace + if type(v) is dict: + continue + + # predefined prefixes xmlns, xml + if a in (XMLSchemaComponent.xmlns, XMLNS.XML): + continue + + if (a not in self.__class__.attributes.keys()) and not\ (self.isAttribute() and self.isReference()): raise SchemaError, '%s, unknown attribute(%s,%s)' \ %(self.getItemTrace(), a, self.attributes[a]) @@ -1358,7 +1365,12 @@ class XMLSchema(XMLSchemaComponent): reader = SchemaReader(base_url=schema.getBaseUrl()) reader._imports = schema.getImportSchemas() reader._includes = schema.getIncludeSchemas() - self._schema = reader.loadFromURL(url) + + # create schema before loading so chameleon include + # will evalute targetNamespace correctly. + self._schema = XMLSchema(schema) + reader.loadFromURL(url, self._schema) + return self._schema