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.

Parameters:
  • xml_path (str) –

    Path to the XML file to transform

Returns:
  • str –

    Transformed XML string

transform_str abstractmethod

transform_str(xml_content: str) -> str

Transform an XML.

Parameters:
  • xml_content (str) –

    XML string to transform

Returns:
  • str –

    Transformed XML string

transform_tree abstractmethod

transform_tree(xml_tree: etree.Element) -> str

Transform an XML tree.

Parameters:
  • xml_tree (etree.Element) –

    XML tree to transform

Returns:
  • str –

    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.

Parameters:
  • xslt (str) –

    XSLT string

  • cwd (str, default: os.getcwd() ) –

    Current working directory

from_file classmethod

from_file(path: str)

Create an XsltProcessor from a file path.

Parameters:
  • path (str) –

    the path to the XSLT file

Returns:
  • –

    the XsltProcessor

from_str classmethod

from_str(string: str)

Create an XsltProcessor from a string.

Parameters:
  • string (str) –

    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.

Parameters:
  • tree (etree.Element) –

    the etree.Element tree

Returns:
  • –

    the XsltProcessor

transform_file

transform_file(xml_path: str) -> str

Transforms an XML file with the xslt string.

Parameters:
  • xml_path (str) –

    Path to the XML file to transform

Returns:
  • str –

    Transformed XML string

transform_str

transform_str(xml_content: str) -> str

Transforms a xml with the xslt string.

Parameters:
  • xml_content (str) –

    XML string to transform

Returns:
  • str –

    Transformed XML string

transform_tree

transform_tree(xml_tree: etree.Element) -> str

Transforms an XML tree with the xslt string.

Parameters:
  • xml_tree (etree.Element) –

    XML tree to transform

Returns:
  • str –

    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.

Parameters:
  • xml_path (str) –

    Path to the XML file to transform

Returns:
  • str –

    Transformed XML string

transform_str abstractmethod

transform_str(xml_content: str) -> str

Transform an XML.

Parameters:
  • xml_content (str) –

    XML string to transform

Returns:
  • str –

    Transformed XML string

transform_tree abstractmethod

transform_tree(xml_tree: etree.Element) -> str

Transform an XML tree.

Parameters:
  • xml_tree (etree.Element) –

    XML tree to transform

Returns:
  • str –

    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.

Parameters:
  • xslt (str) –

    XSLT string

  • cwd (str, default: os.getcwd() ) –

    Current working directory

from_file classmethod

from_file(path: str)

Create an XsltProcessor from a file path.

Parameters:
  • path (str) –

    the path to the XSLT file

Returns:
  • –

    the XsltProcessor

from_str classmethod

from_str(string: str)

Create an XsltProcessor from a string.

Parameters:
  • string (str) –

    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.

Parameters:
  • tree (etree.Element) –

    the etree.Element tree

Returns:
  • –

    the XsltProcessor

transform_file

transform_file(xml_path: str) -> str

Transforms an XML file with the xslt string.

Parameters:
  • xml_path (str) –

    Path to the XML file to transform

Returns:
  • str –

    Transformed XML string

transform_str

transform_str(xml_content: str) -> str

Transforms a xml with the xslt string.

Parameters:
  • xml_content (str) –

    XML string to transform

Returns:
  • str –

    Transformed XML string

transform_tree

transform_tree(xml_tree: etree.Element) -> str

Transforms an XML tree with the xslt string.

Parameters:
  • xml_tree (etree.Element) –

    XML tree to transform

Returns:
  • str –

    Transformed XML string