Skip to content

Utilities

elematic.util

This module provides utility functions for importing and exporting MatML documents in XML and JSON formats.

export_json(matml_doc, outfile=None, **kwargs)

Renders a MatML document object to a JSON file or a string.

Parameters:

Name Type Description Default
matml_doc MatMLDoc

The MatML document object to render.

required
outfile str | None

The output file path. If None, the JSON string is returned.

None
**kwargs

Additional keyword arguments for SerializerConfig.

{}

export_xml(matml_doc, outfile=None, **kwargs)

Renders a MatML document object to an XML file or a string.

Parameters:

Name Type Description Default
matml_doc MatMLDoc

The MatML document object to render.

required
outfile str | None

The output file path. If None, the XML string is returned.

None
**kwargs

Additional keyword arguments for SerializerConfig.

{}

import_json(json, **kwargs)

Imports a MatML document from a JSON file or string.

Parameters:

Name Type Description Default
json str

The JSON file path or JSON string.

required
**kwargs

Additional keyword arguments for ParserConfig.

{}

import_xml(xml, **kwargs)

Imports a MatML document from an XML file or string.

Parameters:

Name Type Description Default
xml str

The XML file path or XML string.

required
**kwargs

Additional keyword arguments for ParserConfig.

{}