예제 #1
0
    def gatherNamespaces(self):
        '''This method must execute once..  Grab all schemas
        representing each targetNamespace.
        '''
        if self.usedNamespaces is not None:
            return

        self.logger.debug('gatherNamespaces')
        self.usedNamespaces = {}

        # Add all schemas defined in wsdl
        # to used namespace and to the Alias dict
        for schema in self._wsdl.types.values():
            tns = schema.getTargetNamespace()
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(schema), tns),)
            if self.usedNamespaces.has_key(tns) is False:
                self.usedNamespaces[tns] = []
            self.usedNamespaces[tns].append(schema)
            NAD.add(tns)

        # Add all xsd:import schema instances
        # to used namespace and to the Alias dict
        for k, v in SchemaReader.namespaceToSchema.items():
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(v), k),)
            if self.usedNamespaces.has_key(k) is False:
                self.usedNamespaces[k] = []
            self.usedNamespaces[k].append(v)
            NAD.add(k)
예제 #2
0
    def gatherNamespaces(self):
        '''This method must execute once..  Grab all schemas
        representing each targetNamespace.
        '''
        if self.usedNamespaces is not None:
            return

        self.logger.debug('gatherNamespaces')
        self.usedNamespaces = {}

        # Add all schemas defined in wsdl
        # to used namespace and to the Alias dict
        for schema in self._wsdl.types.values():
            tns = schema.getTargetNamespace()
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(schema), tns),)
            if self.usedNamespaces.has_key(tns) is False:
                self.usedNamespaces[tns] = []
            self.usedNamespaces[tns].append(schema)
            NAD.add(tns)

        # Add all xsd:import schema instances
        # to used namespace and to the Alias dict
        for k,v in SchemaReader.namespaceToSchema.items():
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(v), k),)
            if self.usedNamespaces.has_key(k) is False:
                self.usedNamespaces[k] = []
            self.usedNamespaces[k].append(v)
            NAD.add(k)
예제 #3
0
    def gatherNamespaces(self):
        '''This method must execute once..  Grab all schemas
        representing each targetNamespace.
        '''
        if self.usedNamespaces is not None:
            return

        self.logger.debug('gatherNamespaces')
        self.usedNamespaces = {}

        def recommended_ns(s):
            tns = s.getTargetNamespace()
            recommended = None
            for k, v in s.attributes.get('xmlns', {}).items():
                if k == '':
                    continue
                if v == tns:
                    recommended = k
                    break

            return recommended

        # Add all schemas defined in wsdl
        # to used namespace and to the Alias dict
        for schema in self._wsdl.types.values():
            tns = schema.getTargetNamespace()
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(schema), tns),)
            if self.usedNamespaces.has_key(tns) is False:
                self.usedNamespaces[tns] = []
            self.usedNamespaces[tns].append(schema)
            NAD.add(tns, recommended_ns(schema))

        # Add all xsd:import schema instances
        # to used namespace and to the Alias dict
        for k,v in SchemaReader.namespaceToSchema.items():
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(v), k),)
            if self.usedNamespaces.has_key(k) is False:
                self.usedNamespaces[k] = []
            self.usedNamespaces[k].append(v)
            NAD.add(k, recommended_ns(v))