Skip to content

xslmaker

Implement the XslMaker class.

XslMaker

Make an xsl file to combine with the intermediate xml file.

To convert the intermediate xml to a fullfledged giellatekno document a combination of three xsl files + the intermediate xml file is needed.

Source code in /home/anders/projects/CorpusTools/corpustools/xslmaker.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class XslMaker:
    """Make an xsl file to combine with the intermediate xml file.

    To convert the intermediate xml to a fullfledged  giellatekno document
    a combination of three xsl files + the intermediate xml file is needed.
    """

    def __init__(self, xslfile):
        """Initialise the XslMaker class.

        Args:
            xslfile (str): a string containing the path to the xsl file.
        """
        self.filename = xslfile

    @property
    def logfile(self):
        """Returns the name of the logfile."""
        return self.filename + ".log"

    @property
    def xsl(self):
        """Returns an etree of the xsl file.

        Raises:
            ConversionException: In case of an xml syntax error
        """
        xsl = etree.parse(os.path.join(HERE, "xslt/preprocxsl.xsl"))
        transformer = etree.XSLT(xsl)

        common_xsl_path = os.path.join(HERE, "xslt/common.xsl").replace(" ", "%20")

        return transformer(
            self.filename,
            commonxsl=etree.XSLT.strparam(f"file://{common_xsl_path}"),
        )

    @property
    def transformer(self):
        """Make an etree.XSLT transformer.

        Raises:
            util.ConversionException: in case of invalid XML in the xsl file.

        Returns:
            (etree.XSLT): an etree.XSLT transformer
        """
        return etree.XSLT(self.xsl)

logfile property

Returns the name of the logfile.

transformer property

Make an etree.XSLT transformer.

Raises:

Type Description
util.ConversionException

in case of invalid XML in the xsl file.

Returns:

Type Description
etree.XSLT

an etree.XSLT transformer

xsl property

Returns an etree of the xsl file.

Raises:

Type Description
ConversionException

In case of an xml syntax error

__init__(xslfile)

Initialise the XslMaker class.

Parameters:

Name Type Description Default
xslfile str

a string containing the path to the xsl file.

required
Source code in /home/anders/projects/CorpusTools/corpustools/xslmaker.py
36
37
38
39
40
41
42
def __init__(self, xslfile):
    """Initialise the XslMaker class.

    Args:
        xslfile (str): a string containing the path to the xsl file.
    """
    self.filename = xslfile