From 7e85dd9fc82b3fef703a0befafa578eb503377de Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Sat, 1 Nov 2003 02:49:48 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: XMLSchema.py -- fixed an unknown bug caused by overlooking the potential namespace contents of a "types" node. ---------------------------------------------------------------------- --- XMLSchema.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/XMLSchema.py b/XMLSchema.py index 9344a05..a410b68 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -197,6 +197,12 @@ class DOMAdapterInterface: """ raise NotImplementedError, 'adapter method not implemented' + + def getParentNode(self): + """returns parent element in DOMAdapter or None + """ + raise NotImplementedError, 'adapter method not implemented' + def loadDocument(self, file): """load a Document from a file object file -- @@ -255,6 +261,11 @@ class DOMAdapter(DOMAdapterInterface): def getTagName(self): return self.__node.tagName + def getParentNode(self): + if self.__node.parentNode.nodeType == self.__node.ELEMENT_NODE: + return DOMAdapter(self.__node.parentNode) + return None + def getNamespace(self, prefix): """prefix -- deference namespace prefix in node's context. Ascends parent nodes until found. @@ -387,6 +398,8 @@ class XMLSchemaComponent(XMLBase): parent = parent._parent() ns = parent.attributes[XMLSchemaComponent.xmlns].get(prefix or\ XMLSchemaComponent.xmlns_key) + if not ns and isinstance(parent, WSDLToolsAdapter): + raise SchemaError, 'unknown prefix %s' %prefix return ns def getAttribute(self, attribute): @@ -927,7 +940,22 @@ class XMLSchema(XMLSchemaComponent): return self.attributes.get('finalDefault') def load(self, node): - self.setAttributes(node) + pnode = node.getParentNode() + if pnode: + pname = SplitQName(pnode.getTagName())[1] + if pname == 'types': + attributes = {} + self.setAttributes(pnode) + attributes.update(self.attributes) + self.setAttributes(node) + for k,v in attributes['xmlns'].items(): + if not self.attributes['xmlns'].has_key(k): + self.attributes['xmlns'][k] = v + else: + self.setAttributes(node) + else: + self.setAttributes(node) + self.targetNamespace = self.getTargetNamespace() contents = self.getContents(node)