Exemplo n.º 1
0
Arquivo: types.py Projeto: akx/foamy
def type_from_xmlschema_element(nsmap, context, tns, element, defer=False):
    complex_type = self_or_child(element, NS.tag("schema", "complexType"))
    simple_type = self_or_child(element, NS.tag("schema", "simpleType"))
    simple_content = self_or_child(element, SIMPLE_CONTENT_TAG)

    if simple_type is not None:
        cls = SimpleType
    elif simple_content is not None:
        cls = SimpleContentType
    elif complex_type is not None:
        if complex_type.find(NS.tag("schema", "all")) is not None:
            cls = ComplexAllType
        elif complex_type.find(NS.tag("schema", "sequence")) is not None:
            cls = ComplexSequenceType
        else:
            raise ValueError("Unparsable complexType!")
    else:
        cls = Type

    #logger.debug("%s -> %s", element, cls)

    type = cls(context, tns, element.get("name"))
    if not defer:
        nsmap = nsmap.augment(element.nsmap)
        type.parse_xmlschema_element(nsmap, element)

    return type
Exemplo n.º 2
0
def type_from_xmlschema_element(nsmap, context, tns, element, defer=False):
    complex_type = self_or_child(element, NS.tag("schema", "complexType"))
    simple_type = self_or_child(element, NS.tag("schema", "simpleType"))
    simple_content = self_or_child(element, SIMPLE_CONTENT_TAG)

    if simple_type is not None:
        cls = SimpleType
    elif simple_content is not None:
        cls = SimpleContentType
    elif complex_type is not None:
        if complex_type.find(NS.tag("schema", "all")) is not None:
            cls = ComplexAllType
        elif complex_type.find(NS.tag("schema", "sequence")) is not None:
            cls = ComplexSequenceType
        else:
            raise ValueError("Unparsable complexType!")
    else:
        cls = Type

    #logger.debug("%s -> %s", element, cls)

    type = cls(context, tns, element.get("name"))
    if not defer:
        nsmap = nsmap.augment(element.nsmap)
        type.parse_xmlschema_element(nsmap, element)

    return type
Exemplo n.º 3
0
 def parse_xmlschema_element(self, nsmap, element):
     super(ComplexAllType, self).parse_xmlschema_element(nsmap, element)
     complex_type = self_or_child(element, NS.tag("schema", "complexType"))
     self.all = self.parse_type_list(
         nsmap, complex_type.find(NS.tag("schema", "all")))
     for type in self.all:
         type.min_occurs = 0
Exemplo n.º 4
0
Arquivo: types.py Projeto: akx/foamy
 def parse_xmlschema_element(self, nsmap, element):
     super(SimpleContentType, self).parse_xmlschema_element(nsmap, element)
     simple_content = self_or_child(element, SIMPLE_CONTENT_TAG)
     ext_tag = simple_content.find(NS.tag("schema", "extension"))
     if ext_tag is None:
         raise XMLValueError("simpleContent without s:extension...", simple_content)
     base = ext_tag.get("base")
     self.base = self.context.resolve_type(nsmap.to_qname(base))
     self._read_attributes(nsmap, simple_content)
Exemplo n.º 5
0
 def parse_xmlschema_element(self, nsmap, element):
     super(SimpleContentType, self).parse_xmlschema_element(nsmap, element)
     simple_content = self_or_child(element, SIMPLE_CONTENT_TAG)
     ext_tag = simple_content.find(NS.tag("schema", "extension"))
     if ext_tag is None:
         raise XMLValueError("simpleContent without s:extension...",
                             simple_content)
     base = ext_tag.get("base")
     self.base = self.context.resolve_type(nsmap.to_qname(base))
     self._read_attributes(nsmap, simple_content)
Exemplo n.º 6
0
Arquivo: types.py Projeto: akx/foamy
 def parse_xmlschema_element(self, nsmap, element):
     super(ComplexAllType, self).parse_xmlschema_element(nsmap, element)
     complex_type = self_or_child(element, NS.tag("schema", "complexType"))
     self.all = self.parse_type_list(nsmap, complex_type.find(NS.tag("schema", "all")))
     for type in self.all:
         type.min_occurs = 0
Exemplo n.º 7
0
Arquivo: types.py Projeto: akx/foamy
 def parse_xmlschema_element(self, nsmap, element):
     super(ComplexSequenceType, self).parse_xmlschema_element(nsmap, element)
     complex_type = self_or_child(element, NS.tag("schema", "complexType"))
     self.sequence = self.parse_type_list(nsmap, complex_type.find(NS.tag("schema", "sequence")))
Exemplo n.º 8
0
 def parse_xmlschema_element(self, nsmap, element):
     super(ComplexSequenceType,
           self).parse_xmlschema_element(nsmap, element)
     complex_type = self_or_child(element, NS.tag("schema", "complexType"))
     self.sequence = self.parse_type_list(
         nsmap, complex_type.find(NS.tag("schema", "sequence")))