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
¶
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:
|
context
|
A ParseContext instance.
TYPE:
|
initial_nsmap
|
An optional namespace map for resolving prefixed element names. |
| 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:
|
descriptor
|
A descriptor for the BPMN element.
TYPE:
|
parent_uri
|
The URI of the parent BPMN element.
TYPE:
|
context
|
The parsing context for the element.
TYPE:
|
nsmap
|
An optional namespace map for resolving prefixed element names. |
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The created BPMN element, or None if the element type is not supported. |
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
¶
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:
|
descriptor
|
The element descriptor containing metadata about the element properties.
TYPE:
|
key
|
The string representation of the child element name.
TYPE:
|
ns_map
|
The namespace map to use for resolving the QName. |
| 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:
|
child_descriptor
|
Descriptor providing details about how the value maps to a child element. If None, the original value is returned as-is.
TYPE:
|
is_many
|
Indicates whether the descriptor expects multiple child elements.
TYPE:
|
ns_map
|
A dictionary mapping namespace prefixes to their corresponding URIs. |
parent_uri
|
The parent namespace URI for the resulting child elements.
TYPE:
|
context
|
The parsing context for the element.
TYPE:
|
| 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. |