Search code examples
xslt-2.0saxon

xsl:output media-type with the command-line


When I use the following in my XSLT file, Saxon outputs the file with a .htm extension

<xsl:output method="html"
        version="5.0"
        doctype-system="about:legacy-compat"
        encoding="UTF-8"
        indent="yes"
        media-type="text/html"/>

However when I run the transformation through the CLI and pass the the output argument using !media-type=text/html Saxon outputs the file with an xml extension

Below is the command I use, am I doing something wrong?

java  -jar /Users/Stephane/XSLT_DEV/saxon/saxon9he.jar -s:/Users/Stephane/XSLT_DEV/S1000D/xml/ -o:/Users/Stephane/XSLT_DEV/S1000D/html/ -xsl:$file cssPath='../xslt/assets' imagesPath='graphics/' !method='html' !version='5.0' !encoding='UTF-8' !indent='yes' !media-type='text/html';

Solution

  • Automatic generation of an output file name occurs only in one specific case: where you use the command line to process an directory of input files to generate a directory of output files. It makes the decision based on the value of xsl:output/@media-type, ignoring any value for !media-type supplied on the command line. No particular reason, but that's what it does. The value will be ".xml", ".html", or ".txt".

    In all other cases, the output file name is exactly what you choose it to be.