Version 0.5.2, released 2008 August 7
XML's many virtues do not include conciseness. This is generally not a problem, but in cases where there is more markup than text -- such as an XSLT transformation script or a set of RDF statements -- it can be difficult to see the important content of a document behind the forest of angle-brackets and closing tags.
Lx provides an alternative for just this situation. These Java
classes define a compact syntax for XML, and an implementation of
the SAX XMLReader which turns it into a stream of SAX
events.
Another way of looking at this is that Lx provides a notation for XML in lisp-style sexps, similar in some ways to SXML, though that's mostly concerned with going the other way. Or, put yet another way, this is a sexp-to-SAX converter in Java.
Here's the XSLT identity transformation:
;; The XSLT identity transformation
(lx:namespace ((#f "http://www.w3.org/1999/XSL/Transform"))
(stylesheet version: 1.0
(template match: "node()|@*"
(copy
(apply-templates select: "@*|node()")))))
This is pure XSLT, and would be accepted as such by any XSL transformation engine which allows you to plug in an alternative parser. It's trivially easy, for example, to have Saxon use stylesheets written in Lx syntax:
% CLASSPATH=.../saxon8.jar:.../lx.jar
% java net.sf.saxon.Transform \
-y uk.me.nxg.lx.reader.LxReader \
input.xml script.lx
See the javadocs for more examples of use.
The (lx:namespace ...) structure maps the null
prefix to the XSLT namespace within its scope. Elements
are indicated with an open parenthesis followed by the element name, and
stretch to the matching parenthesis. Attributes are indicated by
the attribute name plus a colon, then the attribute value.
Full documentation is in the package javadocs. There are also distributed examples.
Versions:
| 0.5.2 | Fix tokeniser bug. |
| 0.5.1 | Various documentation improvements |
| 0.5 |
|
| 0.4 |
|
| 0.3 | Strings "..." now preferred over [...], and now allow newlines and escapes |
| 0.2-1 | Documentation improvements |
| 0.2 | First public release |
If you wish to build the package from scratch, download the source distribution, above, and build it with ant build.
The package is Copyright 2003-2008 Norman Gray, and is released under the terms of the GNU General Public Licence (though contact me if you have other licensing requirements).