Beispiel #1
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        # Handle wsdl:arrayType objects
        attrs = {
            attr.qname.text: attr
            for attr in self._attributes if attr.qname
        }
        array_type = attrs.get(
            '{http://schemas.xmlsoap.org/soap/encoding/}arrayType')
        if array_type:
            name = generator.get_name()
            if isinstance(self._element, Group):
                return [(name,
                         Sequence([
                             Any(max_occurs='unbounded',
                                 restrict=array_type.array_type)
                         ]))]
            else:
                return [(name, self._element)]

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
Beispiel #2
0
    def __init__(self, element=None, attributes=None,
                 restriction=None, extension=None, qname=None, is_global=False):
        if element and type(element) == list:
            element = Sequence(element)

        self.name = self.__class__.__name__ if qname else None
        self._element = element
        self._attributes = attributes or []
        self._restriction = restriction
        self._extension = extension
        super(ComplexType, self).__init__(qname=qname, is_global=is_global)
Beispiel #3
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        if self._extension:
            name = generator.get_name()
            if not hasattr(self._extension, 'elements_nested'):
                result.append((name, Element(name, self._extension)))
            else:
                result.extend(self._extension.elements_nested)

        if self._restriction and not self._element:
            # So this is a workaround to support wsdl:arrayType. This doesn't
            # actually belong here but for now it's the easiest way to achieve
            # this. What this does it that is checks if the restriction
            # contains an arrayType attribute and then use that to retrieve
            # the xsd type for the array. (We ignore AnyAttributes here)
            attrs = {
                attr.qname.text: attr
                for attr in self._attributes if attr.qname
            }
            array_type = attrs.get(
                '{http://schemas.xmlsoap.org/soap/encoding/}arrayType')
            if array_type:
                name = generator.get_name()
                result.append((name,
                               Sequence([
                                   Any(max_occurs='unbounded',
                                       restrict=array_type.array_type)
                               ])))
            else:
                name = generator.get_name()
                if not hasattr(self._restriction, 'elements_nested'):
                    result.append((name, Element(name, self._restriction)))
                else:
                    result.extend(self._restriction.elements_nested)

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result