XSLTC - an XSLT compiler
Version 0.4
Portions (c) 2000 Olivier Gerardin <ogerardin@vo.lu>
This is XSLTC, an XSLT stylesheet compiler, based on TransforMiix.
XSLTC takes as input an XSLT stylesheet, and generates C++ code. The
executable that is generated from this code is expected to have the same
behaviour as the source stylesheet when run through an XSLT processor,
only much faster.
XSLTC is still at an early stage; however, it works, it implements all
the functionalities present in TransforMiix, and it's up to 70% faster.
Optimization is the next step.
This work is not related to Sun's
XSLT Compiler.
Changes from version 0.3
-
Completely rewrote the XPath expression parser. The new parser is fully
recursive and hopefully compliant with the spec.
-
Implemented additional functions generate-id() and document(). Note: document('')
is not implemented.
-
Reorganized the Expr inheritance graph. Specifically:
-
Removed the notion of a Pattern class; patterns are now considered as a
special case of expressions
-
Created common superclass for binary exprs (BinaryExpr)
-
Updated to expat 1.1. Now comment nodes are not ignored any more.
-
Fixed whitespace processing
-
Caught up with some of the latest TransforMiix updates
-
Optimized calls to template without actual parameters
-
Fixed handling of string constants with embedded quotes
Obtaining XSLTC
XSLTC is available in C++ source form
Older versions:
Building XSLTC
The Makefiles in XSLTC try to apply some of the techniques described in
Peter Miller's very interesting paper "Recursive Make Considered
Harmful" (http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html)
GNU-make is required. Currently, the build process is known to work
with:
-
Linux RedHat 6.1 / gcc version 2.95
-
Sun Solaris 2.6 / Workshop C++ calmost allompiler 4.2
-
Windows / Microsoft Visual C++ (with a few tweaks)
First you should check the main Makefile, namely src/Makefile,
for settings that are best suited for your configuration. Here are the
most useful:
-
CXX=xxx Sets the C++ compiler you wish to use.
-
CPPFLAGS=xxx Flags passed to the preprocessor. These
may include -I for additional include directories, or -D
for additional symbol definitions
-
CXXFLAGS=xxx Flags passed to the C++ compiler. These
may include debugging/optimization flags such as -g/-O
-
LDFLAGS=xxx Flags passed to the linker. These may
include -L for additional library search directories, and -l
for additional libraries
Then you should edit the file src/depend.sh to make sure it is
correctly configured.
Next try building XSLTC by simply typing:
$ make
After a successful compilation, you should have an executable named
'xsltc' in the bin directory, and a library named 'libxsltc.a'
in the lib directory.
If you manage to compile XSLTC on another platform, please let me know
so that I can update the Makefiles and/or doc. If by chance you happen
to be an autoconf specialist willing to devote some time to making XSLTC
use autoconf, feel free to do so...
Compiling stylesheets
Suppose you have a stylesheet named foo.xsl, and you want to compile it.
First you must generate the C++ code:
# xsltc foo.xsl Foo
This creates two files, Foo.h which contains the Foo class interface,
and Foo.cpp which contains the actual class code.
Next you must C++ compile Foo.cpp. The typical command is something
like:
# CC Foo.cpp -I${XSLTCDIR}/include -L${XSLTCDIR}/lib -lxsltc -o foo
where ${XSLTCDIR} is the XSLT root directory. Your actual command
might be different, check your C++ compiler doc.
Using compiled stylesheets
The executable compiled from XSLTC-generated code understands the following
syntax:
xxxxx [-i xml-file] [-o output-file]
You may use '-' in place of xml-file or output-file to
specify standard input/output, which is also the default if the option
is omitted.
E.g.:
# foo -i testdata.xml -o result.xml
Licence
XSLTC is licensed under the Mozilla Public Licence 1.1
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations under
the License.
The complete text of the license is available here
Credits
Feedback
Constructive criticism is always welcome, as well as bug reports and fixes,
ideas for improvement, and personal gifts.
I don't plan to set up a CVS server for XSLTC in the near future, so
send any patches to me and I'll try to integrate them in the next release.
Olivier Gerardin <ogerardin@vo.lu>
-