Browse Source

Add Utility.DOM.looseNamespaces

Allows processing of wsdl that has elements with an undefined namespace

Signed-off-by: Pamela McA'Nulty <pamela@webreply.com>
main
Pamela McA'Nulty 14 years ago
parent
commit
d0f8e8179d
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      src/wstools/Utility.py

+ 7
- 1
src/wstools/Utility.py View File

@@ -216,6 +216,8 @@ class DOM:
also provides some basic abstractions so that the rest of the also provides some basic abstractions so that the rest of the
package need not care about actual DOM implementation in use.""" package need not care about actual DOM implementation in use."""


looseNamespaces = False # if can't find a referenced namespace, try the default one
# Namespace stuff related to the SOAP specification. # Namespace stuff related to the SOAP specification.


NS_SOAP_ENV_1_1 = 'http://schemas.xmlsoap.org/soap/envelope/' NS_SOAP_ENV_1_1 = 'http://schemas.xmlsoap.org/soap/envelope/'
@@ -532,6 +534,7 @@ class DOM:
attrkey = (self.NS_XMLNS, prefix) attrkey = (self.NS_XMLNS, prefix)
DOCUMENT_NODE = node.DOCUMENT_NODE DOCUMENT_NODE = node.DOCUMENT_NODE
ELEMENT_NODE = node.ELEMENT_NODE ELEMENT_NODE = node.ELEMENT_NODE
orig_node = node
while 1: while 1:
if node is None: if node is None:
raise DOMException('Value for prefix %s not found.' % prefix) raise DOMException('Value for prefix %s not found.' % prefix)
@@ -545,7 +548,10 @@ class DOM:
raise DOMException('Value for prefix %s not found.' % prefix) raise DOMException('Value for prefix %s not found.' % prefix)
node = node.parentNode node = node.parentNode
if node.nodeType == DOCUMENT_NODE: if node.nodeType == DOCUMENT_NODE:
raise DOMException('Value for prefix %s not found.' % prefix)
if DOM.looseNamespaces:
return self.findTargetNS(orig_node)
else:
raise DOMException('Value for prefix %s not found.' % prefix)


def findDefaultNS(self, node): def findDefaultNS(self, node):
"""Return the current default namespace uri for the given node.""" """Return the current default namespace uri for the given node."""


Loading…
Cancel
Save