Skip to content

xml

autocorpus.ac_bioc.xml ¤

This module provides XML serialization and deserialization for BioC objects.

Classes¤

BioCXML ¤

XML serialization for BioC objects.

Functions¤
dumps(collection) staticmethod ¤

Serialize a BioCCollection object to an XML string.

Parameters:

Name Type Description Default
collection BioCCollection

The BioCCollection object to serialize.

required

Returns:

Name Type Description
str str

The XML string representation of the collection.

Source code in autocorpus/ac_bioc/xml.py
11
12
13
14
15
16
17
18
19
20
21
22
@staticmethod
def dumps(collection: BioCCollection) -> str:
    """Serialize a BioCCollection object to an XML string.

    Args:
        collection (BioCCollection): The BioCCollection object to serialize.

    Returns:
        str: The XML string representation of the collection.
    """
    root = collection.to_xml()
    return ET.tostring(root, encoding="unicode")
loads(xml_str) staticmethod ¤

Deserialize an XML string into a BioCCollection object.

Parameters:

Name Type Description Default
xml_str str

The XML string to deserialize.

required

Returns:

Name Type Description
BioCCollection BioCCollection

The deserialized BioCCollection object.

Source code in autocorpus/ac_bioc/xml.py
24
25
26
27
28
29
30
31
32
33
34
35
@staticmethod
def loads(xml_str: str) -> BioCCollection:
    """Deserialize an XML string into a BioCCollection object.

    Args:
        xml_str (str): The XML string to deserialize.

    Returns:
        BioCCollection: The deserialized BioCCollection object.
    """
    root = ET.fromstring(xml_str)
    return BioCCollection.from_xml(root)