From 3bb0aed0733d1710bae1fa7e9228702b70d0a80c Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Tue, 11 May 2004 01:09:51 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: XMLSchema.py -- added some code to generate user interpretable exceptions. BEFORE: File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/ZSI/wstools/Utility.py", line 600, in __getitem__ return self.data[key] KeyError: u'xtvd' AFTER: File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/ZSI/wstools/XMLSchema.py", line 465, in getQNameAttribute raise KeyError, "targetNamespace(%s) collection(%s) has no item(%s)"\ KeyError: u'targetNamespace(urn:TMSWebServices) collection(types) has no item(xtvd)' ---------------------------------------------------------------------- --- XMLSchema.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/XMLSchema.py b/XMLSchema.py index 99a5022..3eb9352 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -456,11 +456,22 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): tdc = self.attributes.get(attribute) if tdc: parent = GetSchema(self) - if parent.targetNamespace == tdc.getTargetNamespace(): - obj = getattr(parent, collection)[tdc.getName()] - elif parent.imports.has_key(tdc.getTargetNamespace()): - schema = parent.imports[tdc.getTargetNamespace()].getSchema() - obj = getattr(schema, collection)[tdc.getName()] + targetNamespace = tdc.getTargetNamespace() + if parent.targetNamespace == targetNamespace: + item = tdc.getName() + try: + obj = getattr(parent, collection)[item] + except KeyError, ex: + raise KeyError, "targetNamespace(%s) collection(%s) has no item(%s)"\ + %(targetNamespace, collection, item) + elif parent.imports.has_key(targetNamespace): + schema = parent.imports[targetNamespace].getSchema() + item = tdc.getName() + try: + obj = getattr(schema, collection)[item] + except KeyError, ex: + raise KeyError, "targetNamespace(%s) collection(%s) has no item(%s)"\ + %(targetNamespace, collection, item) return obj def getXMLNS(self, prefix=None):