animedex.render.xml

Lossless XML payload adapter.

The adapter converts xml.etree.ElementTree.Element trees into plain dictionaries without making backend-specific decisions. It is used by XML-speaking backends such as ANN, while semantic handling stays in the backend rich-model layer.

XmlInput

animedex.render.xml.XmlInput

alias of str | bytes

TAG_KEY

animedex.render.xml.TAG_KEY = '_tag'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

ATTRS_KEY

animedex.render.xml.ATTRS_KEY = '_attrs'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

TEXT_KEY

animedex.render.xml.TEXT_KEY = '_text'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

TAIL_KEY

animedex.render.xml.TAIL_KEY = '_tail'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

CHILDREN_KEY

animedex.render.xml.CHILDREN_KEY = '_children'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

CHILDREN_BY_TAG_KEY

animedex.render.xml.CHILDREN_BY_TAG_KEY = '_children_by_tag'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

element_to_dict

animedex.render.xml.element_to_dict(element: Element) Dict[str, Any][source]

Convert an ElementTree element into a lossless dictionary.

The returned shape preserves element name, attributes, direct text, tail text, ordered children, and grouped children by tag. The ordered child list is authoritative; the grouped map is a convenience index that always stores lists, even for tags that appear once.

Parameters:

element (xml.etree.ElementTree.Element) – Parsed XML element.

Returns:

Lossless dictionary representation of element.

Return type:

dict

xml_text_to_dict

animedex.render.xml.xml_text_to_dict(xml: str | bytes) Dict[str, Any][source]

Parse an XML string or bytes payload and convert it to a dict.

XML parse errors are wrapped as ApiError with reason="upstream-decode" so backend callers can surface a stable error vocabulary.

Parameters:

xml (str or bytes) – XML text or bytes.

Returns:

Lossless dictionary representation of the root element.

Return type:

dict

Raises:

ApiError – When xml is not well-formed XML.

children_by_tag

animedex.render.xml.children_by_tag(node: Dict[str, Any], tag: str) list[source]

Return grouped child nodes for tag from an adapted node.

Parameters:
Returns:

Child nodes with matching tag, in original order.

Return type:

list

node_text

animedex.render.xml.node_text(node: Dict[str, Any]) str | None[source]

Return the node’s direct text content when present.

Parameters:

node (dict) – Node produced by element_to_dict().

Returns:

Direct text content, or None.

Return type:

str or None

selftest

animedex.render.xml.selftest() bool[source]

Smoke-test the XML adapter.

Parses a representative mixed-content document and verifies tag, attribute, text, child-order, and repeated-child preservation.

Returns:

True on success.

Return type:

bool