YML ā€“ Why a Markup Language?!

YML 2.5.5 of We Aug 24 2016 ā€“ Copyleft 2007-2016, Volker Birk ā€“ Download 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 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, then the include statement searches these paths. If YML_PATH is not set, the local directory . is searched for files.

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 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

The file xml2yml.ysl2 has to be in YML_PATH.

-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, then the include statement searches these paths. If YML_PATH is not set, the local directory . is searched for files.

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.

Older versions

YML 2.5.2

YML 2.5.1

YML 2.5.0

YML 2.4.3

YML 2.3.12

YML 2.3.11

YML 2.3.10

YML 2.3.8

YML 2.3.7

YML 2.3.5

YML 2.2.4

YML 2.2.3

YML 2.2.1

YML 2.2.0

YML 2.1.17

YML 2.1.14

YML 2.1.13

YML 2.1.12

YML 2.1.7

YML 2.1.6

YML 2.1.5

YML 2.1.2

YML 2.0.36

YML 2.0.35

To the Homepage of version 1 of YML...

<< back to YSLT ^Top^ (source)