Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
<-- extensibility element (2) --> *
?
<-- extensibility element (3) -->
?
<-- extensibility element (4) --> *
*
<-- extensibility element (5) --> *
"""
name = qname_attr(xmlelement, "name", definitions.target_namespace)
port_name = qname_attr(xmlelement, "type", definitions.target_namespace)
# The soap:binding element contains the transport method and
# default style attribute for the operations.
soap_node = xmlelement.find("soap:binding", namespaces=cls.nsmap)
transport = soap_node.get("transport")
supported_transports = [
"http://schemas.xmlsoap.org/soap/http",
"http://www.w3.org/2003/05/soap/bindings/HTTP/",
]
if transport not in supported_transports:
raise NotImplementedError(
"The binding transport %s is not supported (only soap/http)"
% (transport)
)
itemType = QName
{any attributes with non-schema Namespace}...>
Content: (annotation?, (simpleType?))
The use of the simpleType element child and the itemType attribute is
mutually exclusive.
:param node: The XML node
:type node: lxml.etree._Element
:param parent: The parent XML node
:type parent: lxml.etree._Element
"""
item_type = qname_attr(node, "itemType")
if item_type:
sub_type = self._get_type(item_type.text)
else:
subnodes = list(node)
child = subnodes[-1] # skip annotation
sub_type = self.visit_simple_type(child, node)
return xsd_types.ListType(sub_type)
id = ID
{any attributes with non-schema Namespace}...>
Content: (annotation?,
(simpleType?, (
minExclusive | minInclusive | maxExclusive | maxInclusive |
totalDigits |fractionDigits | length | minLength |
maxLength | enumeration | whiteSpace | pattern)*))
:param node: The XML node
:type node: lxml.etree._Element
:param parent: The parent XML node
:type parent: lxml.etree._Element
"""
base_name = qname_attr(node, "base")
if base_name:
return self._get_type(base_name)
annotation, children = self._pop_annotation(list(node))
if children[0].tag == tags.simpleType:
return self.visit_simple_type(children[0], node)
This is the entrypoint for parsing an xml document.
:param xmlelement: The XML element to parse
:type xmlelements: lxml.etree._Element
:param schema: The parent XML schema
:type schema: zeep.xsd.Schema
:param allow_none: Allow none
:type allow_none: bool
:param context: Optional parsing context (for inline schemas)
:type context: zeep.xsd.context.XmlParserContext
:return: dict or None
"""
context = context or XmlParserContext()
instance_type = qname_attr(xmlelement, xsi_ns("type"))
xsd_type = None
if instance_type:
xsd_type = schema.get_type(instance_type, fail_silently=True)
xsd_type = xsd_type or self.type
return xsd_type.parse_xmlelement(
xmlelement,
schema,
allow_none=allow_none,
context=context,
schema_type=self.type,
)
Definition::
*
?
<-- extensibility element -->
:param wsdl: The parent definition instance
:type wsdl: zeep.wsdl.wsdl.Definition
:param xmlelement: The XML node
:type xmlelement: lxml.etree._Element
:rtype: zeep.wsdl.definitions.Port
"""
name = xmlelement.get("name")
binding_name = qname_attr(xmlelement, "binding", wsdl.target_namespace)
return definitions.Port(name, binding_name=binding_name, xmlelement=xmlelement)
Content: (annotation?, (group | all | choice | sequence)?,
((attribute | attributeGroup)*, anyAttribute?))
:param node: The XML node
:type node: lxml.etree._Element
:param parent: The parent XML node
:type parent: lxml.etree._Element
"""
base_name = qname_attr(node, "base")
base_type = self._get_type(base_name)
annotation, children = self._pop_annotation(list(node))
element = None
attributes = []
if children:
child = children[0]
if child.tag in (tags.group, tags.all, tags.choice, tags.sequence):
children.pop(0)
element = self.process(child, node)
attributes = self._process_attributes(node, children)
return base_type, element, attributes
if not is_global:
result = self.process_ref_attribute(node, array_type=array_type)
if result:
return result
attribute_form = node.get("form", self.document._attribute_form)
if attribute_form == "qualified" or is_global:
name = qname_attr(node, "name", self.document._target_namespace)
else:
name = etree.QName(node.get("name"))
annotation, items = self._pop_annotation(list(node))
if items:
xsd_type = self.visit_simple_type(items[0], node)
else:
node_type = qname_attr(node, "type")
if node_type:
xsd_type = self._get_type(node_type)
else:
xsd_type = xsd_types.AnyType()
# TODO: We ignore 'prohobited' for now
required = node.get("use") == "required"
default = node.get("default")
attr = xsd_elements.Attribute(
name, type_=xsd_type, default=default, required=required
)
# Only register global elements
if is_global:
self.register_attribute(name, attr)
def process_reference(self, node, **kwargs):
ref = qname_attr(node, "ref")
if not ref:
return
ref = self._create_qname(ref)
if node.tag == tags.element:
cls = xsd_elements.RefElement
elif node.tag == tags.attribute:
cls = xsd_elements.RefAttribute
elif node.tag == tags.group:
cls = xsd_elements.RefGroup
elif node.tag == tags.attributeGroup:
cls = xsd_elements.RefAttributeGroup
return cls(node.tag, ref, self.schema, **kwargs)