Contents
The aim of this project is to try to reimplement MakeIndex via XSLT 2.0. The author just wishes to demonstrate the possibility of such a usage of XSLT, not to make a production software. The future of this project depends on the response of potential users as well as upon author's personal need. The program is licensed under GPL.
The stylesheets require XSLT 2.0 processor, e.g. Saxon v.8.x.
The stylesheets are modular and work in the following steps:
Output of these steps can be written to an auxiliary file for testing purposes. The structure of these files is described in the documented Relax NG Schema.
The last step is output formatting. Format useful for subsequent processing by LaTEX is demonstrated here (format-index.xsl).
The project was described in detail in the Bulletin of the Czechoslovak TEX Users' Group No. 1/2006 (in Czech).
2.1. | musixdoc.idx |
2.2. | prstyn.idx |
2.3. | makeindex.rng/.xsd |
2.4. | parse-index.xsl |
2.5. | testsort.xsl |
2.6. | sort-index.xsl |
2.7. | format-index.xsl |
2.8. | makeindex.xsl |
Modified file from MusixTEX documentation, bugs will be reported during processing. For testing only, encofing ISO 8859-1.
Note: The bugs were introduced intentionally for testing purposes.
Another test file, encoding ISO 8859-2.
Definition of the structure of auxiliary files in Relax NG. Conversion to an XML Schema was done by trang. The Relax NG Schema was also transformed into HTML. Transformation was achieved by "Tool for annotation of Relax NG Schemas".
Stylesheet for parsing a file created by LaTEX. Parameter
index
contains a comma separated list of input files, optional parameter
enc
specifies their encoding (default is UTF-8). Other parameters reflect properties
of the same names defined in the MakeIndex style file. Some of them are used in regular
expressions, therefore special characters must be escaped by a backslash.
The stylesheet is intended to be imported to another stylesheet but it can be used as
such for testing. The name of the initial template is parsed-index
. The output must be
valid with respect to
makeindex.rng/.xsd.
If the input files file1.idx
and file2.idx
have
ISO 8859-2 encoding, the output file file.xml
should have CP852 encoding and
saxon8
is the script for invoking the Saxon
processor, we make use of command:
saxon8 -o file.xml -it parsed-index parse-index.xsl index=file1.idx,file2.idx enc=iso-8859-2 !encoding=cp852 |
Auxiliary test stylesheet, see sort-index.xsl.
This stylesheet performs alphabetical sorting accorting to criteria given in
parameters. Only elements the name of which is supplied in the keyword
parameter are
sorted. The initial template for testing purposes is sorted-index
and the output must
be valid with respect to makeindex.rng/.xsd. The stylesheet cannot be used as such but must be
imported together with another stylesheet generating the same output as parse-index.xsl.
If testsort.xsl is used with similar requirements as above, we use:
saxon8 -o file.xml -it sorted-index testsort.xsl index=file1.idx,file2.idx enc=iso-8859-2 !encoding=cp852 |
This stylesheet formats alphabetically sorted output for further processng by
LaTEX. The properties defined by MakeIndex style file are here specified via parameters.
The stylesheet has two initial templates: noheaders
which does not create headers, and
headers
which does create them. Some letters do not have primary sort order, therefor
thay must not appear in the header. The equivalence for the Czech and Slovak languages s defined in
function zw:key
. Similar functions for other languages must be created by yourselves.
This auxiliary file just imports stylesheets parse-index.xsl, sort-index.xsl, and format-index.xsl.
The project was inspired by lecture Michael Kay: Schema-aware XSLT Processing presented on conference XML Prague in June 2005.
Other references:
xslt-indexing.zip, 39 KiB