dcclib.transformation

Transformable

Bases: ABC

Abstract base class for classes that can perform transformations on a string, file path, or tree structure.

transform_file abstractmethod

transform_file(xml_path: str) -> str

Transform an XML file. @param xml_path: Path to the XML file to transform @returns: Transformed XML string

transform_str abstractmethod

transform_str(xml_content: str) -> str

Transform an XML. @param xml_content: XML string to transform @returns: Transformed XML string

transform_tree abstractmethod

transform_tree(xml_tree: etree.Element) -> str

Transform an XML tree. @param xml_tree: XML tree to transform @returns: Transformed XML string

XsltProcessor

XsltProcessor(xslt: str, cwd: str = os.getcwd())

Bases: Constructible, Transformable

Processor for XSLT transformations.

Initializes the XSLT processor with the given XSLT string. :param xslt: XSLT string :param cwd: Current working directory

from_str classmethod

from_str(string: str)

Create an XsltProcessor from a string. :param string: the content of the XSLT schema :returns: the XsltProcessor

from_tree classmethod

from_tree(tree: etree.Element)

Create an XsltProcessor from an etree.Element tree. :param tree: the etree.Element tree :returns: the XsltProcessor

transform_file

transform_file(xml_path: str) -> str

Transforms an XML file with the xslt string. :param xml_path: Path to the XML file to transform :returns: Transformed XML string

transform_str

transform_str(xml_content: str) -> str

Transforms a xml with the xslt string. :param xml_content: XML string to transform :returns: Transformed XML string

transform_tree

transform_tree(xml_tree: etree.Element) -> str

Transforms an XML tree with the xslt string. :param xml_tree: XML tree to transform :returns: Transformed XML string

transformable

Transformable

Bases: ABC

Abstract base class for classes that can perform transformations on a string, file path, or tree structure.

transform_file abstractmethod

transform_file(xml_path: str) -> str

Transform an XML file. @param xml_path: Path to the XML file to transform @returns: Transformed XML string

transform_str abstractmethod

transform_str(xml_content: str) -> str

Transform an XML. @param xml_content: XML string to transform @returns: Transformed XML string

transform_tree abstractmethod

transform_tree(xml_tree: etree.Element) -> str

Transform an XML tree. @param xml_tree: XML tree to transform @returns: Transformed XML string

xslt

XsltProcessor

XsltProcessor(xslt: str, cwd: str = os.getcwd())

Bases: Constructible, Transformable

Processor for XSLT transformations.

Initializes the XSLT processor with the given XSLT string. :param xslt: XSLT string :param cwd: Current working directory

from_str classmethod

from_str(string: str)

Create an XsltProcessor from a string. :param string: the content of the XSLT schema :returns: the XsltProcessor

from_tree classmethod

from_tree(tree: etree.Element)

Create an XsltProcessor from an etree.Element tree. :param tree: the etree.Element tree :returns: the XsltProcessor

transform_file

transform_file(xml_path: str) -> str

Transforms an XML file with the xslt string. :param xml_path: Path to the XML file to transform :returns: Transformed XML string

transform_str

transform_str(xml_content: str) -> str

Transforms a xml with the xslt string. :param xml_content: XML string to transform :returns: Transformed XML string

transform_tree

transform_tree(xml_tree: etree.Element) -> str

Transforms an XML tree with the xslt string. :param xml_tree: XML tree to transform :returns: Transformed XML string