示例#1
0
 def getprefixes(self):
     """
     Add prefixes foreach namespace referenced by parameter types.
     """
     namespaces = []
     for l in (self.params, self.types):
         for t, r in l:
             ns = r.namespace()
             if ns[1] is None: continue
             if ns[1] in namespaces: continue
             if Namespace.xs(ns) or Namespace.xsd(ns):
                 continue
             namespaces.append(ns[1])
             if t == r: continue
             ns = t.namespace()
             if ns[1] is None: continue
             if ns[1] in namespaces: continue
             namespaces.append(ns[1])
     i = 0
     namespaces.sort()
     known_uris = {v: k for k, v in self.wsdl.root.nsprefixes.iteritems()}
     for u in namespaces:
         if u in known_uris:
             ns = (known_uris[u], u)
         else:
             p = self.nextprefix()
             ns = (p, u)
         self.prefixes.append(ns)
 def getprefixes(self):
     """
     Add prefixes foreach namespace referenced by parameter types.
     """
     namespaces = []
     for l in (self.params, self.types):
         for t, r in l:
             ns = r.namespace()
             if ns[1] is None:
                 continue
             if ns[1] in namespaces:
                 continue
             if Namespace.xs(ns) or Namespace.xsd(ns):
                 continue
             namespaces.append(ns[1])
             if t == r:
                 continue
             ns = t.namespace()
             if ns[1] is None:
                 continue
             if ns[1] in namespaces:
                 continue
             namespaces.append(ns[1])
     namespaces.sort()
     for u in namespaces:
         p = self.nextprefix()
         ns = (p, u)
         self.prefixes.append(ns)
示例#3
0
    def getprefixes(self):
        """Add prefixes for each namespace referenced by parameter types."""
        namespaces = []
        for l in (self.params, self.types):
            for t, r in l:
                ns = r.namespace()
                if ns[1] is None: continue
                if ns[1] in namespaces: continue
                if Namespace.xs(ns) or Namespace.xsd(ns):
                    continue
                namespaces.append(ns[1])
                if t == r: continue
                ns = t.namespace()
                if ns[1] is None: continue
                if ns[1] in namespaces: continue
                namespaces.append(ns[1])
        i = 0

        if self.wsdl.options.sortNamespaces:
            namespaces.sort()

        for u in namespaces:
            p = self.nextprefix()
            ns = (p, u)
            self.prefixes.append(ns)
示例#4
0
 def parsed(self, context):
     node = context.document
     # xsd root
     if node.name == 'schema' and Namespace.xsd(node.namespace()):
         self.examine(node)
         return
     # look deeper
     context = DocumentContext()
     for child in node:
         context.document = child
         self.parsed(context)
 def skip(self, attr):
     """
     Get whether to skip (filter-out) the specified attribute.
     @param attr: An attribute.
     @type attr: I{Attribute}
     @return: True if should be skipped.
     @rtype: bool
     """
     ns = attr.namespace()
     skip = (
         Namespace.xmlns[1],
         'http://schemas.xmlsoap.org/soap/encoding/',
         'http://schemas.xmlsoap.org/soap/envelope/',
         'http://www.w3.org/2003/05/soap-envelope',
     )
     return ( Namespace.xs(ns) or ns[1] in skip )
示例#6
0
 def skip(attr):
     """
     Get whether to skip (filter-out) the specified attribute.
     @param attr: An attribute.
     @type attr: I{Attribute}
     @return: True if should be skipped.
     @rtype: bool
     """
     ns = attr.namespace()
     skip = (
         Namespace.xmlns[1],
         'http://schemas.xmlsoap.org/soap/encoding/',
         'http://schemas.xmlsoap.org/soap/envelope/',
         'http://www.w3.org/2003/05/soap-envelope',
     )
     return ( Namespace.xs(ns) or ns[1] in skip )
示例#7
0
 def qualify(self):
     """
     Convert attribute values, that are references to other
     objects, into I{qref}.  Qualified using the default document namespace.
     Since many WSDLs are written improperly: when the document does
     not define its default namespace, the schema target namespace is used
     to qualify references.
     """
     defns = self.root.defaultNamespace()
     if Namespace.none(defns):
         defns = self.schema.tns
     for a in self.autoqualified():
         ref = getattr(self, a)
         if ref is None:
             continue
         if isqref(ref):
             continue
         qref = qualify(ref, self.root, defns)
         log.debug('%s, convert %s="%s" to %s', self.id, a, ref, qref)
         setattr(self, a, qref)
示例#8
0
文件: sxbase.py 项目: mringg/suds
 def qualify(self):
     """
     Convert attribute values, that are references to other
     objects, into I{qref}.  Qualfied using default document namespace.
     Since many wsdls are written improperly: when the document does
     not define a default namespace, the schema target namespace is used
     to qualify references.
     """
     defns = self.root.defaultNamespace()
     if Namespace.none(defns):
         defns = self.schema.tns
     for a in self.autoqualified():
         ref = getattr(self, a)
         if ref is None:
             continue
         if isqref(ref):
             continue
         qref = qualify(ref, self.root, defns)
         log.debug('%s, convert %s="%s" to %s', self.id, a, ref, qref)
         setattr(self, a, qref)
示例#9
0
文件: sxbase.py 项目: dalwise/suds
    def qualify(self):
        """
        Convert reference attribute values into a I{qref}.

        Constructed I{qref} used the default document namespace. Since many
        WSDL schemas are written improperly: when the document does not define
        its default namespace, the schema target namespace is used to qualify
        references.

        """
        defns = self.root.defaultNamespace()
        if Namespace.none(defns):
            defns = self.schema.tns
        for a in self.autoqualified():
            ref = getattr(self, a)
            if ref is None:
                continue
            if isqref(ref):
                continue
            qref = qualify(ref, self.root, defns)
            log.debug("%s, convert %s='%s' to %s", self.id, a, ref, qref)
            setattr(self, a, qref)
示例#10
0
 def parsed(self, context):
     root = context.root
     if Namespace.xsd(root.namespace()):
         self.examine(root)
     else:
         pass