3.2. xml - XML serialization and deserialization

This package contains functionality for serialization and deserialization of BaSyx Python SDK objects into/from XML.

xml_serialization: The module offers a function to write an ObjectStore to a given file.

xml_deserialization: The module offers a function to create an ObjectStore from a given xml document.

3.2.1. xml.xml_serialization - Serialization from AAS-objects to XML

Module for serializing Asset Administration Shell data to the official XML format

How to use:

  • For generating an XML-File from a AbstractObjectStore, check out the function write_aas_xml_file().

  • For serializing any object to an XML fragment, that fits the XML specification from ‘Details of the Asset Administration Shell’, chapter 5.4, you can either use object_to_xml_element(), which serializes a given object and returns it as _Element, or write_aas_xml_element(), which does the same thing, but writes the _Element to a file instead of returning it. As a third alternative, you can also use the functions <class_name>_to_xml() directly.

Attention

Unlike the XML deserialization and the JSON (de-)serialization, the XML serialization only supports BinaryIO and not TextIO. Thus, if you open files by yourself, you have to open them in binary mode, see the mode table of open().

# wb = open for writing + binary mode
with open("example.xml", "wb") as fp:
    write_aas_xml_file(fp, object_store)
abstract_classes_to_xml(tag: str, obj: object) _Element

Generates an XML element and adds attributes of abstract base classes of obj.

If the object obj is inheriting from any abstract AAS class, this function adds all the serialized information of those abstract classes to the generated element.

Parameters:
  • tag – Tag of the element

  • obj – An object of the AAS

Returns:

Parent element with the serialized information from the abstract classes

administrative_information_to_xml(obj: AdministrativeInformation, tag: str = '{https://admin-shell.io/aas/3/0}administration') _Element

Serialization of objects of class AdministrativeInformation to XML

Parameters:
  • obj – Object of class AdministrativeInformation

  • tag – Namespace+Tag of the serialized element. Default is aas:administration

Returns:

Serialized _Element object

annotated_relationship_element_to_xml(obj: AnnotatedRelationshipElement, tag: str = '{https://admin-shell.io/aas/3/0}annotatedRelationshipElement') _Element

Serialization of objects of class AnnotatedRelationshipElement to XML

Parameters:
  • obj – Object of class AnnotatedRelationshipElement

  • tag – Namespace+Tag of the serialized element (optional): Default is aas:annotatedRelationshipElement

Returns:

Serialized _Element object

asset_administration_shell_to_xml(obj: AssetAdministrationShell, tag: str = '{https://admin-shell.io/aas/3/0}assetAdministrationShell') _Element

Serialization of objects of class AssetAdministrationShell to XML

Parameters:
  • obj – Object of class AssetAdministrationShell

  • tag – Namespace+Tag of the ElementTree object. Default is aas:assetAdministrationShell

Returns:

Serialized _Element object

asset_information_to_xml(obj: AssetInformation, tag: str = '{https://admin-shell.io/aas/3/0}assetInformation') _Element

Serialization of objects of class AssetInformation to XML

Parameters:
  • obj – Object of class AssetInformation

  • tag – Namespace+Tag of the ElementTree object. Default is aas:assetInformation

Returns:

Serialized _Element object

basic_event_element_to_xml(obj: BasicEventElement, tag: str = '{https://admin-shell.io/aas/3/0}basicEventElement') _Element

Serialization of objects of class BasicEventElement to XML

Parameters:
  • obj – Object of class BasicEventElement

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:basicEventElement

Returns:

Serialized _Element object

blob_to_xml(obj: Blob, tag: str = '{https://admin-shell.io/aas/3/0}blob') _Element

Serialization of objects of class Blob to XML

Parameters:
  • obj – Object of class Blob

  • tag – Namespace+Tag of the serialized element. Default is aas:blob

Returns:

Serialized _Element object

boolean_to_xml(obj: bool) str

Serialize a boolean to XML

Parameters:

obj – Boolean (True, False)

Returns:

String in the XML accepted form (true, false)

capability_to_xml(obj: Capability, tag: str = '{https://admin-shell.io/aas/3/0}capability') _Element

Serialization of objects of class Capability to XML

Parameters:
  • obj – Object of class Capability

  • tag – Namespace+Tag of the serialized element, default is aas:capability

Returns:

Serialized _Element object

concept_description_to_xml(obj: ConceptDescription, tag: str = '{https://admin-shell.io/aas/3/0}conceptDescription') _Element

Serialization of objects of class ConceptDescription to XML

Parameters:
  • obj – Object of class ConceptDescription

  • tag – Namespace+Tag of the ElementTree object. Default is aas:conceptDescription

Returns:

Serialized _Element object

data_element_to_xml(obj: DataElement) _Element

Serialization of objects of class DataElement to XML

Parameters:

obj – Object of class DataElement

Returns:

Serialized _Element object

data_specification_content_to_xml(obj: DataSpecificationContent, tag: str = '{https://admin-shell.io/aas/3/0}dataSpecificationContent') _Element

Serialization of objects of class DataSpecificationContent to XML

Parameters:
  • obj – Object of class DataSpecificationContent

  • tag – Namespace+Tag of the ElementTree object. Default is aas:dataSpecificationContent

Returns:

Serialized _Element object

data_specification_iec61360_to_xml(obj: DataSpecificationIEC61360, tag: str = '{https://admin-shell.io/aas/3/0}dataSpecificationIec61360') _Element

Serialization of objects of class DataSpecificationIEC61360 to XML

Parameters:
  • obj – Object of class DataSpecificationIEC61360

  • tag – Namespace+Tag of the ElementTree object. Default is aas:dataSpecificationIec61360

Returns:

Serialized _Element object

embedded_data_specification_to_xml(obj: EmbeddedDataSpecification, tag: str = '{https://admin-shell.io/aas/3/0}embeddedDataSpecification') _Element

Serialization of objects of class EmbeddedDataSpecification to XML

Parameters:
  • obj – Object of class EmbeddedDataSpecification

  • tag – Namespace+Tag of the ElementTree object. Default is aas:embeddedDataSpecification

Returns:

Serialized _Element object

entity_to_xml(obj: Entity, tag: str = '{https://admin-shell.io/aas/3/0}entity') _Element

Serialization of objects of class Entity to XML

Parameters:
  • obj – Object of class Entity

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:entity

Returns:

Serialized _Element object

extension_to_xml(obj: Extension, tag: str = '{https://admin-shell.io/aas/3/0}extension') _Element

Serialization of objects of class Extension to XML

Parameters:
  • obj – Object of class Extension

  • tag – Namespace+Tag of the serialized ElementTree object. Default is aas:extension

Returns:

Serialized _Element object

file_to_xml(obj: File, tag: str = '{https://admin-shell.io/aas/3/0}file') _Element

Serialization of objects of class File to XML

Parameters:
  • obj – Object of class File

  • tag – Namespace+Tag of the serialized element. Default is aas:file

Returns:

Serialized _Element object

key_to_xml(obj: Key, tag: str = '{https://admin-shell.io/aas/3/0}key') _Element

Serialization of objects of class Key to XML

Parameters:
  • obj – Object of class Key

  • tag – Namespace+Tag of the returned element. Default is aas:key

Returns:

Serialized _Element object

lang_string_set_to_xml(obj: LangStringSet, tag: str) _Element

Serialization of objects of class LangStringSet to XML

Parameters:
  • obj – Object of class LangStringSet

  • tag – Namespace+Tag name of the returned XML element.

Returns:

Serialized _Element object

multi_language_property_to_xml(obj: MultiLanguageProperty, tag: str = '{https://admin-shell.io/aas/3/0}multiLanguageProperty') _Element

Serialization of objects of class MultiLanguageProperty to XML

Parameters:
  • obj – Object of class MultiLanguageProperty

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:multiLanguageProperty

Returns:

Serialized _Element object

object_store_to_xml_element(data: AbstractObjectStore) _Element

Serialize a set of AAS objects to an Asset Administration Shell as _Element. This function is used internally by write_aas_xml_file() and shouldn’t be called directly for most use-cases.

Parameters:

dataObjectStore which contains different objects of the AAS meta model which should be serialized to an XML file

object_to_xml_element(obj: object) _Element

Serialize a single object to an _Element.

Parameters:

obj – The object to serialize

operation_to_xml(obj: Operation, tag: str = '{https://admin-shell.io/aas/3/0}operation') _Element

Serialization of objects of class Operation to XML

Parameters:
  • obj – Object of class Operation

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:operation

Returns:

Serialized _Element object

operation_variable_to_xml(obj: SubmodelElement, tag: str = '{https://admin-shell.io/aas/3/0}operationVariable') _Element

Serialization of SubmodelElement to the XML OperationVariable representation Since we don’t implement the OperationVariable class, which is just a wrapper for a single SubmodelElement, elements are serialized as the aas:value child of an aas:operationVariable element.

Parameters:
  • obj – Object of class SubmodelElement

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:operationVariable

Returns:

Serialized _Element object

property_to_xml(obj: Property, tag: str = '{https://admin-shell.io/aas/3/0}property') _Element

Serialization of objects of class Property to XML

Parameters:
  • obj – Object of class Property

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:property

Returns:

Serialized _Element object

qualifier_to_xml(obj: Qualifier, tag: str = '{https://admin-shell.io/aas/3/0}qualifier') _Element

Serialization of objects of class Qualifier to XML

Parameters:
  • obj – Object of class Qualifier

  • tag – Namespace+Tag of the serialized ElementTree object. Default is aas:qualifier

Returns:

Serialized _Element object

range_to_xml(obj: Range, tag: str = '{https://admin-shell.io/aas/3/0}range') _Element

Serialization of objects of class Range to XML

Parameters:
  • obj – Object of class Range

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:range

Returns:

Serialized _Element object

reference_element_to_xml(obj: ReferenceElement, tag: str = '{https://admin-shell.io/aas/3/0}referenceElement') _Element

Serialization of objects of class ReferenceElement to XMl

Parameters:
  • obj – Object of class ReferenceElement

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:referenceElement

Returns:

Serialized _Element object

reference_to_xml(obj: Reference, tag: str = '{https://admin-shell.io/aas/3/0}reference') _Element

Serialization of objects of class Reference to XML

Parameters:
  • obj – Object of class Reference

  • tag – Namespace+Tag of the returned element. Default is aas:reference

Returns:

Serialized _Element object

relationship_element_to_xml(obj: RelationshipElement, tag: str = '{https://admin-shell.io/aas/3/0}relationshipElement') _Element

Serialization of objects of class RelationshipElement to XML

Parameters:
  • obj – Object of class RelationshipElement

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:relationshipElement

Returns:

Serialized _Element object

resource_to_xml(obj: Resource, tag: str = '{https://admin-shell.io/aas/3/0}resource') _Element

Serialization of objects of class Resource to XML

Parameters:
  • obj – Object of class Resource

  • tag – Namespace+Tag of the serialized element. Default is aas:resource

Returns:

Serialized _Element object

specific_asset_id_to_xml(obj: SpecificAssetId, tag: str = '{https://admin-shell.io/aas/3/0}specifidAssetId') _Element

Serialization of objects of class SpecificAssetId to XML

Parameters:
  • obj – Object of class SpecificAssetId

  • tag – Namespace+Tag of the ElementTree object. Default is aas:identifierKeyValuePair

Returns:

Serialized _Element object

submodel_element_collection_to_xml(obj: SubmodelElementCollection, tag: str = '{https://admin-shell.io/aas/3/0}submodelElementCollection') _Element

Serialization of objects of class SubmodelElementCollection to XML

Parameters:
  • obj – Object of class SubmodelElementCollection

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:submodelElementCollection

Returns:

Serialized _Element object

submodel_element_list_to_xml(obj: SubmodelElementList, tag: str = '{https://admin-shell.io/aas/3/0}submodelElementList') _Element

Serialization of objects of class SubmodelElementList to XML

Parameters:
  • obj – Object of class SubmodelElementList

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:submodelElementList

Returns:

Serialized _Element object

submodel_element_to_xml(obj: SubmodelElement) _Element

Serialization of objects of class SubmodelElement to XML

Parameters:

obj – Object of class SubmodelElement

Returns:

Serialized _Element object

submodel_to_xml(obj: Submodel, tag: str = '{https://admin-shell.io/aas/3/0}submodel') _Element

Serialization of objects of class Submodel to XML

Parameters:
  • obj – Object of class Submodel

  • tag – Namespace+Tag of the serialized element (optional). Default is aas:submodel

Returns:

Serialized _Element object

value_list_to_xml(obj: Set[ValueReferencePair], tag: str = '{https://admin-shell.io/aas/3/0}valueList') _Element

Serialization of objects of class ValueList to XML

todo: couldn’t find it in the official schema, so guessing how to implement serialization

Parameters:
  • obj – Object of class ValueList

  • tag – Namespace+Tag of the serialized element. Default is aas:valueList

Returns:

Serialized _Element object

value_reference_pair_to_xml(obj: ValueReferencePair, tag: str = '{https://admin-shell.io/aas/3/0}valueReferencePair') _Element

Serialization of objects of class ValueReferencePair to XML

Parameters:
  • obj – Object of class ValueReferencePair

  • tag – Namespace+Tag of the serialized element. Default is aas:valueReferencePair

Returns:

Serialized _Element object

write_aas_xml_element(file: str | bytes | PathLike | BinaryIO, obj: object, **kwargs) None

Serialize a single object to XML. Namespace declarations are added to the object itself, as there is no surrounding environment element.

Parameters:
  • file – A filename or file-like object to write the XML-serialized data to

  • obj – The object to serialize

  • kwargs – Additional keyword arguments to be passed to write()

write_aas_xml_file(file: str | bytes | PathLike | BinaryIO, data: AbstractObjectStore, **kwargs) None

Write a set of AAS objects to an Asset Administration Shell XML file according to ‘Details of the Asset Administration Shell’, chapter 5.4

Parameters:
  • file – A filename or file-like object to write the XML-serialized data to

  • dataObjectStore which contains different objects of the AAS meta model which should be serialized to an XML file

  • kwargs – Additional keyword arguments to be passed to write()

3.2.2. xml.xml_deserialization - Deserialization from XML to AAS-objects

Module for deserializing Asset Administration Shell data from the official XML format

This module provides the following functions for parsing XML documents:

These functions take a decoder class as keyword argument, which allows parsing in failsafe (default) or non-failsafe mode. Parsing stripped elements - used in the HTTP adapter - is also possible. It is also possible to subclass the default decoder class and provide an own decoder.

In failsafe mode errors regarding missing attributes and elements or invalid values are caught and logged. In non-failsafe mode any error would abort parsing. Error handling is done only by _failsafe_construct() in this module. Nearly all constructor functions are called by other constructor functions via _failsafe_construct(), so an error chain is constructed in the error case, which allows printing stacktrace-like error messages like the following in the error case (in failsafe mode of course):

KeyError: aas:id on line 252 has no attribute with name idType!
    -> Failed to construct aas:id on line 252 using construct_identifier!
    -> Failed to construct aas:conceptDescription on line 247 using construct_concept_description!

Unlike the JSON deserialization, parsing is done top-down. Elements with a specific tag are searched on the level directly below the level of the current xml element (in terms of parent and child relation) and parsed when found. Constructor functions of these elements will then again search for mandatory and optional child elements and construct them if available, and so on.

class AASFromXmlDecoder

The default XML decoder class.

It parses XML documents in a failsafe manner, meaning any errors encountered will be logged and invalid XML elements will be skipped. Most member functions support the object_class parameter. It was introduced so they can be overwritten in subclasses, which allows constructing instances of subtypes.

classmethod construct_administrative_information(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.AdministrativeInformation'>, **_kwargs: ~typing.Any) AdministrativeInformation
classmethod construct_annotated_relationship_element(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.AnnotatedRelationshipElement'>, **_kwargs: ~typing.Any) AnnotatedRelationshipElement
classmethod construct_asset_administration_shell(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.aas.AssetAdministrationShell'>, **_kwargs: ~typing.Any) AssetAdministrationShell
classmethod construct_asset_information(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.aas.AssetInformation'>, **_kwargs: ~typing.Any) AssetInformation
classmethod construct_basic_event_element(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.BasicEventElement'>, **_kwargs: ~typing.Any) BasicEventElement
classmethod construct_blob(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Blob'>, **_kwargs: ~typing.Any) Blob
classmethod construct_capability(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Capability'>, **_kwargs: ~typing.Any) Capability
classmethod construct_concept_description(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.concept.ConceptDescription'>, **_kwargs: ~typing.Any) ConceptDescription
classmethod construct_data_element(element: _Element, abstract_class_name: str = 'DataElement', **kwargs: Any) DataElement

This function does not support the object_class parameter. Overwrite each individual DataElement constructor function instead.

classmethod construct_data_specification_content(element: _Element, **kwargs: Any) DataSpecificationContent

This function doesn’t support the object_class parameter. Overwrite each individual DataSpecificationContent constructor function instead.

classmethod construct_data_specification_iec61360(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.DataSpecificationIEC61360'>, **_kwargs: ~typing.Any) DataSpecificationIEC61360
classmethod construct_definition_type_iec61360(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.DefinitionTypeIEC61360'>, **kwargs: ~typing.Any) DefinitionTypeIEC61360
classmethod construct_embedded_data_specification(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.EmbeddedDataSpecification'>, **_kwargs: ~typing.Any) EmbeddedDataSpecification
classmethod construct_entity(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Entity'>, **_kwargs: ~typing.Any) Entity
classmethod construct_extension(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.Extension'>, **_kwargs: ~typing.Any) Extension
classmethod construct_external_reference(element: ~lxml.etree._Element, namespace: str = '{https://admin-shell.io/aas/3/0}', object_class=<class 'basyx.aas.model.base.ExternalReference'>, **_kwargs: ~typing.Any) ExternalReference
classmethod construct_file(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.File'>, **_kwargs: ~typing.Any) File
classmethod construct_key(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.Key'>, **_kwargs: ~typing.Any) Key
classmethod construct_lang_string_set(element: _Element, expected_tag: str, object_class: Type[LSS], **_kwargs: Any) LSS
classmethod construct_model_reference(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.ModelReference'>, **_kwargs: ~typing.Any) ModelReference

This constructor for ModelReference determines the type of the ModelReference by its keys. If no keys are present, it will default to the type Referable. This behaviour is wanted in read_aas_xml_element().

classmethod construct_model_reference_expect_type(element: ~lxml.etree._Element, type_: ~typing.Type[~basyx.aas.model.base._RT], object_class=<class 'basyx.aas.model.base.ModelReference'>, **_kwargs: ~typing.Any) ModelReference[_RT]

This constructor for ModelReference allows passing an expected type, which is checked against the type of the last key of the reference. This constructor function is used by other constructor functions, since all expect a specific target type.

classmethod construct_multi_language_name_type(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.MultiLanguageNameType'>, **kwargs: ~typing.Any) MultiLanguageNameType
classmethod construct_multi_language_property(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.MultiLanguageProperty'>, **_kwargs: ~typing.Any) MultiLanguageProperty
classmethod construct_multi_language_text_type(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.MultiLanguageTextType'>, **kwargs: ~typing.Any) MultiLanguageTextType
classmethod construct_operation(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Operation'>, **_kwargs: ~typing.Any) Operation
classmethod construct_preferred_name_type_iec61360(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.PreferredNameTypeIEC61360'>, **kwargs: ~typing.Any) PreferredNameTypeIEC61360
classmethod construct_property(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Property'>, **_kwargs: ~typing.Any) Property
classmethod construct_qualifier(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.Qualifier'>, **_kwargs: ~typing.Any) Qualifier
classmethod construct_range(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Range'>, **_kwargs: ~typing.Any) Range
classmethod construct_reference(element: _Element, namespace: str = '{https://admin-shell.io/aas/3/0}', **kwargs: Any) Reference
classmethod construct_reference_element(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.ReferenceElement'>, **_kwargs: ~typing.Any) ReferenceElement
classmethod construct_relationship_element(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.RelationshipElement'>, **_kwargs: ~typing.Any) RelationshipElement
classmethod construct_resource(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.Resource'>, **_kwargs: ~typing.Any) Resource
classmethod construct_short_name_type_iec61360(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.ShortNameTypeIEC61360'>, **kwargs: ~typing.Any) ShortNameTypeIEC61360
classmethod construct_specific_asset_id(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.SpecificAssetId'>, **_kwargs: ~typing.Any) SpecificAssetId
classmethod construct_submodel(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.Submodel'>, **_kwargs: ~typing.Any) Submodel
classmethod construct_submodel_element(element: _Element, **kwargs: Any) SubmodelElement

This function doesn’t support the object_class parameter. Overwrite each individual SubmodelElement/DataElement constructor function instead.

classmethod construct_submodel_element_collection(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.SubmodelElementCollection'>, **_kwargs: ~typing.Any) SubmodelElementCollection
classmethod construct_submodel_element_list(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.submodel.SubmodelElementList'>, **_kwargs: ~typing.Any) SubmodelElementList
classmethod construct_value_list(element: _Element, **_kwargs: Any) Set[ValueReferencePair]

This function doesn’t support the object_class parameter, because ValueList is just a generic type alias.

classmethod construct_value_reference_pair(element: ~lxml.etree._Element, object_class=<class 'basyx.aas.model.base.ValueReferencePair'>, **_kwargs: ~typing.Any) ValueReferencePair
failsafe = True
stripped = False
class StrictAASFromXmlDecoder

Non-failsafe XML decoder. Encountered errors won’t be caught and abort parsing.

failsafe = False
class StrictStrippedAASFromXmlDecoder

Non-failsafe decoder for stripped XML elements.

class StrippedAASFromXmlDecoder

Decoder for stripped XML elements. Used in the HTTP adapter.

stripped = True
class XMLConstructables(value)

This enum is used to specify which type to construct in read_aas_xml_element().

ADMINISTRATIVE_INFORMATION = 5
ANNOTATED_RELATIONSHIP_ELEMENT = 8
ASSET_ADMINISTRATION_SHELL = 24
ASSET_INFORMATION = 25
BASIC_EVENT_ELEMENT = 9
BLOB = 10
CAPABILITY = 11
CONCEPT_DESCRIPTION = 30
DATA_ELEMENT = 31
DATA_SPECIFICATION_CONTENT = 40
DATA_SPECIFICATION_IEC61360 = 41
DEFINITION_TYPE_IEC61360 = 36
EMBEDDED_DATA_SPECIFICATION = 39
ENTITY = 12
EXTENSION = 13
EXTERNAL_REFERENCE = 4
FILE = 14
IEC61360_CONCEPT_DESCRIPTION = 29
KEY = 1
MODEL_REFERENCE = 3
MULTI_LANGUAGE_NAME_TYPE = 34
MULTI_LANGUAGE_PROPERTY = 16
MULTI_LANGUAGE_TEXT_TYPE = 35
OPERATION = 17
PREFERRED_NAME_TYPE_IEC61360 = 37
PROPERTY = 18
QUALIFIER = 6
RANGE = 19
REFERENCE = 2
REFERENCE_ELEMENT = 20
RELATIONSHIP_ELEMENT = 21
RESOURCE = 15
SECURITY = 7
SHORT_NAME_TYPE_IEC61360 = 38
SPECIFIC_ASSET_ID = 26
SUBMODEL = 27
SUBMODEL_ELEMENT = 32
SUBMODEL_ELEMENT_COLLECTION = 22
SUBMODEL_ELEMENT_LIST = 23
VALUE_LIST = 33
VALUE_REFERENCE_PAIR = 28
read_aas_xml_element(file: str | bytes | PathLike | IO, construct: XMLConstructables, failsafe: bool = True, stripped: bool = False, decoder: Type[AASFromXmlDecoder] | None = None, **constructor_kwargs) object | None

Construct a single object from an XML string. The namespaces have to be declared on the object itself, since there is no surrounding environment element.

Parameters:
  • file – A filename or file-like object to read the XML-serialized data from

  • construct – A member of the enum XMLConstructables, specifying which type to construct.

  • failsafe – If true, the document is parsed in a failsafe way: missing attributes and elements are logged instead of causing exceptions. Defect objects are skipped. This parameter is ignored if a decoder class is specified.

  • stripped – If true, stripped XML elements are parsed. See https://git.rwth-aachen.de/acplt/pyi40aas/-/issues/91 This parameter is ignored if a decoder class is specified.

  • decoder – The decoder class used to decode the XML elements

  • constructor_kwargs – Keyword arguments passed to the constructor function

Raises:
Returns:

The constructed object or None, if an error occurred in failsafe mode.

read_aas_xml_file(file: str | bytes | PathLike | IO, **kwargs: Any) DictObjectStore[Identifiable]

A wrapper of read_aas_xml_file_into(), that reads all objects in an empty DictObjectStore. This function supports the same keyword arguments as read_aas_xml_file_into().

Parameters:
  • file – A filename or file-like object to read the XML-serialized data from

  • kwargs – Keyword arguments passed to read_aas_xml_file_into()

Raises:
  • XMLSyntaxErrorNon-failsafe: If the given file(-handle) has invalid XML

  • KeyErrorNon-failsafe: If a required namespace has not been declared on the XML document

  • KeyErrorNon-failsafe: Encountered a duplicate identifier

  • (AASConstraintViolation, KeyError, ValueError)Non-failsafe: Errors during construction of the objects

  • TypeErrorNon-failsafe: Encountered an undefined top-level list (e.g. <aas:submodels1>)

Returns:

A DictObjectStore containing all AAS objects from the XML file

read_aas_xml_file_into(object_store: AbstractObjectStore[Identifiable], file: str | bytes | PathLike | IO, replace_existing: bool = False, ignore_existing: bool = False, failsafe: bool = True, stripped: bool = False, decoder: Type[AASFromXmlDecoder] | None = None, **parser_kwargs: Any) Set[str]

Read an Asset Administration Shell XML file according to ‘Details of the Asset Administration Shell’, chapter 5.4 into a given ObjectStore.

Parameters:
  • object_store – The ObjectStore in which the Identifiable objects should be stored

  • file – A filename or file-like object to read the XML-serialized data from

  • replace_existing – Whether to replace existing objects with the same identifier in the object store or not

  • ignore_existing – Whether to ignore existing objects (e.g. log a message) or raise an error. This parameter is ignored if replace_existing is True.

  • failsafe – If True, the document is parsed in a failsafe way: missing attributes and elements are logged instead of causing exceptions. Defect objects are skipped. This parameter is ignored if a decoder class is specified.

  • stripped – If True, stripped XML elements are parsed. See https://git.rwth-aachen.de/acplt/pyi40aas/-/issues/91 This parameter is ignored if a decoder class is specified.

  • decoder – The decoder class used to decode the XML elements

  • parser_kwargs – Keyword arguments passed to the XMLParser constructor

Raises:
  • XMLSyntaxErrorNon-failsafe: If the given file(-handle) has invalid XML

  • KeyErrorNon-failsafe: If a required namespace has not been declared on the XML document

  • KeyErrorNon-failsafe: Encountered a duplicate identifier

  • KeyError – Encountered an identifier that already exists in the given object_store with both replace_existing and ignore_existing set to False

  • (AASConstraintViolation, KeyError, ValueError)Non-failsafe: Errors during construction of the objects

  • TypeErrorNon-failsafe: Encountered an undefined top-level list (e.g. <aas:submodels1>)

Returns:

A set of Identifiers that were added to object_store

class LSS

alias of TypeVar(‘LSS’, bound=LangStringSet)