Skip to content

factory

A factory to create BPMN elements from an XML dictionary.

FUNCTION DESCRIPTION
attr_is_ignored

Check if an attribute is ignored.

create_bpmn

Create a BPMN element from a root XML dictionary.

create_element_from_dict

Create a BPMN element from a dictionary representation.

extract_nsmap_from_dict

Extract a namespace map from an XML dictionary.

get_attribute_name

Get the attribute name for the factory.

get_child_qname

Compute the qualified name (QName) for a child element based on the provided information.

get_child_value

Processes a value and its descriptor to generate the corresponding child element or list of child elements.

get_property_name

Get the property name for the factory.

Classes

Functions

attr_is_ignored

attr_is_ignored(attr_name: str) -> bool

Check if an attribute is ignored.

PARAMETER DESCRIPTION
attr_name

The name of the attribute to check.

TYPE: str

RETURNS DESCRIPTION
bool

True if the attribute is ignored, False otherwise.

create_bpmn

create_bpmn(
    root_xml_dict: dict,
    context: ParseContext,
    initial_nsmap: Optional[dict[str, str]] = None,
) -> Definitions

Create a BPMN element from a root XML dictionary.

Pass the dict resulting from xmltodict.

PARAMETER DESCRIPTION
root_xml_dict

A root XML dictionary.

TYPE: dict

context

A ParseContext instance.

TYPE: ParseContext

initial_nsmap

An optional namespace map for resolving prefixed element names.

TYPE: Optional[dict[str, str]] DEFAULT: None

RETURNS DESCRIPTION
Definitions

The created BPMN element, or None if the element type is not supported.

create_element_from_dict

create_element_from_dict(
    element_dict: dict,
    descriptor: ElementDescriptor,
    parent_uri: str,
    context: ParseContext,
    nsmap: Optional[dict[str, str]] = None,
) -> Any

Create a BPMN element from a dictionary representation.

PARAMETER DESCRIPTION
element_dict

A dictionary representing a BPMN element.

TYPE: dict

descriptor

A descriptor for the BPMN element.

TYPE: ElementDescriptor

parent_uri

The URI of the parent BPMN element.

TYPE: str

context

The parsing context for the element.

TYPE: ParseContext

nsmap

An optional namespace map for resolving prefixed element names.

TYPE: Optional[dict[str, str]] DEFAULT: None

RETURNS DESCRIPTION
Any

The created BPMN element, or None if the element type is not supported.

extract_nsmap_from_dict

extract_nsmap_from_dict(
    element_dict: dict, nsmap: dict[str, str] | None
) -> dict[str, str]

Extract a namespace map from an XML dictionary.

get_attribute_name

get_attribute_name(
    base_name: str, descriptor: ElementDescriptor, nsmap: dict[str, str]
) -> QName

Get the attribute name for the factory.

get_child_qname

get_child_qname(
    attr_name: QName,
    descriptor: ElementDescriptor,
    key: str,
    ns_map: dict[str, str],
) -> QName | None

Compute the qualified name (QName) for a child element based on the provided information.

This function determines the QName using the type_qname from the descriptor if available. If the type_qname is not present, it parses the QName from the key according to the provided namespace mapping.

PARAMETER DESCRIPTION
attr_name

The qualified name of the attribute to process.

TYPE: QName

descriptor

The element descriptor containing metadata about the element properties.

TYPE: ElementDescriptor

key

The string representation of the child element name.

TYPE: str

ns_map

The namespace map to use for resolving the QName.

TYPE: dict[str, str]

RETURNS DESCRIPTION
QName | None

The computed QName of the child element. Returns None if the QName cannot be resolved.

get_child_value

get_child_value(
    value: Any,
    child_descriptor: Any | None,
    is_many: bool,
    ns_map: dict[str, str],
    parent_uri: str,
    context: ParseContext,
) -> Any

Processes a value and its descriptor to generate the corresponding child element or list of child elements.

This function determines if the given value and descriptor should generate a single child element or a list of elements and applies transformations accordingly. It can handle cases where the value is already a list or needs to be wrapped as a single element.

PARAMETER DESCRIPTION
value

The base value to process.

TYPE: Any

child_descriptor

Descriptor providing details about how the value maps to a child element. If None, the original value is returned as-is.

TYPE: Any | None

is_many

Indicates whether the descriptor expects multiple child elements.

TYPE: bool

ns_map

A dictionary mapping namespace prefixes to their corresponding URIs.

TYPE: dict[str, str]

parent_uri

The parent namespace URI for the resulting child elements.

TYPE: str

context

The parsing context for the element.

TYPE: ParseContext

RETURNS DESCRIPTION
Any

A processed value representing either a single child element or a list of child elements

Any

based on the descriptor and the provided input.

get_property_name

get_property_name(
    base_name: str, descriptor: ElementDescriptor, nsmap: dict[str, str]
) -> str

Get the property name for the factory.

PARAMETER DESCRIPTION
base_name

The base name of the attribute.

TYPE: str

descriptor

The element descriptor.

TYPE: ElementDescriptor

nsmap

The namespace map.

TYPE: dict[str, str]

RETURNS DESCRIPTION
str

The property name.