YML – Why a Markup Language?!

YML 2.7.6 of Thu 25 May 2023 – Copyleft 2007-2023, Volker BirkDownload YML 2

The Toolchain

There are to possibilities to handle YML files: the YML compiler and the YML/YSLT processor.

The YML compiler

The YML compiler is a small Python script. It provides the command line front end yml2c. As default, it compiles your script and outputs to stdout, that usually is the terminal. Your shell provides options to redirect the output into a pipe or a file.

So to use it, just enter yml2c followed by the filename of your YML script:

% yml2c myscript.yml2 > myscript.result

The yml2c command has the following options:

-h, --help

Show a help message and exit.

-C, --old-syntax

Use the syntax of YML 2 version 1.x (compatibility mode).

-D, --emit-linenumbers

Emit line numbers into the resulting XML for debugging purposes.

-E ENCODING, --encoding ENCODING

encoding of input files (default: UTF-8)

-I INCLUDE_PATH, --include=INCLUDE_PATH

Precede YML_PATH by a colon separated INCLUDE_PATH (semicolon separated on Windows) to search for include files.

-m, --omit-empty-parm-tags

Does nothing (only there for compatibility with older versions of yml2c).

-n NORMALIZATION, --normalization=NORMALIZATION

Unicode normalization (none, NFD, NFKD, NFC, NFKC, FCD, default is NFC)

-o FILE, --output=FILE

Don't output to stdout, instead place output in file FILE.

-p, --parse-only

Parse only, then output pyAST as text to stdout. The pyAST is the Abstract Syntax Tree of the parsed script as Python data structure.

-V, --version

Show version and Copyleft information of the YML implementation.

YML_PATH environment variable

If YML_PATH is set to a colon separated path list (semicolon separated on Windows), then the include statement searches these paths. If YML_PATH is not set, the local directory . is searched for files. The system location for .yml2 and .ysl2 files is always searched afterwards.

The YML/YSLT processor

If you're processing more complex tasks, say, executing an YSLT script over some YML files, the YML/YSLT processor will possible fit better to your needs.

To use it, enter yml2proc -y followed by the filename of your YSLT script, followed by the filenames of your YML input files:

% yml2proc -y myscript.ysl2 inputfile.yml2 > myscript.result

The YML/YSLT processor requires the lxml Python library.

The YML/YSLT processor has the following options:

-h, --help

Show a help message and exit.

-C, --old-syntax

Use the syntax of YML 2 version 1.x (compatibility mode).

-D, --emit-linenumbers

Emit line numbers into the resulting XML for debugging purposes.

--debug

switch on debug tracing to stderr; this enables the functionality of the debug(msg) and assert yml:assert(test, msg) YSLT functions.

-E ENCODING, --encoding ENCODING

encoding of input files (default: UTF-8)

-I INCLUDE_PATH, --include=INCLUDE_PATH

Precede YML_PATH by a colon separated INCLUDE_PATH (semicolon separated on Windows) to search for include files.

-m, --omit-empty-parm-tags

Does nothing (only there for compatibility with older versions of yml2proc).

-M, --empty-input-document

Use an empty input document for YSLT or XSLT processing

-n NORMALIZATION, --normalization=NORMALIZATION

Unicode normalization (none, NFD, NFKD, NFC, NFKC, FCD, default is NFC)

-o FILE, --output=FILE

Don't output to stdout, instead place output in file FILE.

-p, --parse-only

Parse only, then output pyAST as text to stdout. The pyAST is the Abstract Syntax Tree of the parsed script as Python data structure.

-e XPATH, --xpath=XPATH

Execute XPath expression XPATH and print result

If you omit -y YSLTSCRIPT, then the result is printed. If you have an additional -y YSLTSCRIPT parameter, then your YSLT script is processing the result of the XPath expression only instead of processing the complete content of your input documents

-P, --pretty

Pretty print output adding whitespace

-x, --xml

Input documents are XML already, don't try to convert them from YML

-y YSLTSCRIPT, --yslt=YSLTSCRIPT

Execute YSLT script YSLTSCRIPT

-X XSLTSCRIPT, --xslt=XSLTSCRIPT

Execute XSLT script XSLTSCRIPT

-d PARAMS, --paramdict=PARAMS

Call XSLT or YSLT script with dictionary PARAMS as XPath parameters. PARAMS is a Python expression which evaluates to a Python dictionary.

Sample:

yml2proc -y myscript -d 'dict(a=3, b="element[@name=2]")'

-s STRINGPARAMS, --stringparamdict=STRINGPARAMS

Call XSLT or YSLT script with dictionary STRINGPARAMS as string parameters. STRINGPARAMS is a Python expression which evaluates to a Python dictionary.

Sample:

yml2proc -y myscript -s 'dict(forename="Hans", name="Meier")'

-Y, --xml2yml

Convert XML to normalized YML. Equivalent to -xy xml2yml.ysl2

-V, --version

Show version and Copyleft information of the YML implementation and exit.

YML_PATH environment variable

If YML_PATH is set to a colon separated path list (semicolon separated on Windows), then the include statement searches these paths. If YML_PATH is not set, the local directory . is searched for files. The system location for .yml2 and .ysl2 files is always searched afterwards.

XSLT Processor

If you want to use YSLT with yml2c instead of yml2proc, you additionally need an XSLT processor.

For that case, I recommend the xsltproc tool.

To process YSLT, just use a pipe with the xsltproc command:

% yml2c customer.ysl2 | xsltproc - customer.xml > customer.html

XML Renicing Tool

Sometimes, you may want to have more human readable output with yml2c. So an XML renicing tool can be helpful.

The XMLStarlet command line tool may be of interest.

Have a look on its fo command.

Windows tool chain

See also the tips for a Windows tool chain for YML.

Downloads

You can here download the newest release of YML.

<< back to YSLT ^Top^ (source)