コード例 #1
0
    def visit_sequence(self, node, parent):
        """
            <sequence
              id = ID
              maxOccurs = (nonNegativeInteger | unbounded) : 1
              minOccurs = nonNegativeInteger : 1
              {any attributes with non-schema Namespace}...>
            Content: (annotation?,
                      (element | group | choice | sequence | any)*)
            </sequence>
        """

        sub_types = [
            tags.annotation, tags.any, tags.choice, tags.element, tags.group,
            tags.sequence
        ]
        min_occurs, max_occurs = _process_occurs_attrs(node)
        result = xsd_elements.Sequence(min_occurs=min_occurs,
                                       max_occurs=max_occurs)

        annotation, items = self._pop_annotation(node.getchildren())
        for child in items:
            assert child.tag in sub_types, child
            item = self.process(child, node)
            assert item is not None
            result.append(item)

        assert None not in result
        return result
コード例 #2
0
ファイル: visitor.py プロジェクト: leomarp/Test2
    def visit_sequence(self, node, parent):
        """
        Definition::

            <sequence
              id = ID
              maxOccurs = (nonNegativeInteger | unbounded) : 1
              minOccurs = nonNegativeInteger : 1
              {any attributes with non-schema Namespace}...>
            Content: (annotation?,
                      (element | group | choice | sequence | any)*)
            </sequence>

        :param node: The XML node
        :type node: lxml.etree._Element
        :param parent: The parent XML node
        :type parent: lxml.etree._Element

        """

        sub_types = [
            tags.annotation,
            tags.any,
            tags.choice,
            tags.element,
            tags.group,
            tags.sequence,
        ]
        min_occurs, max_occurs = _process_occurs_attrs(node)
        result = xsd_elements.Sequence(min_occurs=min_occurs,
                                       max_occurs=max_occurs)

        annotation, children = self._pop_annotation(list(node))
        for child in children:
            if child.tag not in sub_types:
                raise self._create_error(
                    "Unexpected element %s in xsd:sequence" % child.tag, child)

            item = self.process(child, node)
            assert item is not None
            result.append(item)

        assert None not in result
        return result