Version @VERSION@
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.
Here's the XSLT identity transformation:
(lx:namespace (("xsl" "http://www.w3.org/1999/XSL/Transform"))
(xsl:stylesheet version: 1.0
(xsl:template match: "node()|@*"
(xsl:copy
(xsl:apply-templates select: "@*|node()")))))
The (lx:namespace ...)
structure maps the xsl prefix to the XSLT
namespace within it. 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.
Download the distribution from https://nxg.me.uk/dist/lx/. The source repository is available at https://code.nxg.name/nxg/lx.
If you wish to build the package from scratch, download the source
distribution from one of the sites above, and build it with ant
build
. You need to have the JUnit jar in the path, in order to run
the tests with ant test
.
Add the lx.jar file to your CLASSPATH.
The class uk.me.nxg.lx.reader.LxReader
is an implementation of the
standard class org.xml.sax.XMLReader
. You can therefore use it in the
same way, with the only difference being that the parse()
method
consumes a file in Lx syntax, rather than one with pointy-brackets.
Some Java XSLT processors (for example Saxon, with its -y
option)
allow you to specify an alternative implementation of XMLReader. In
cases like this, you can write your XSLT stylesheet, or other XML,
using Lx, and use it immediately.
You can also convert .lx files to .xml files at the command line. See
java -jar lx.jar --help
for instructions.
To build from source, use ant jars
; to run the tests, use ant
-Djunit.classpath=/path/to/junit3.jar test
.
In directory docs/, with full details in directory javadocs/.
The package is copyright 2003-2012 Norman Gray, and is released under the terms of the GNU General Public Licence. See http://www.gnu.org/licenses/gpl.html, and the file LICENCE in the distribution (though contact me if you have other licensing requirements).
Norman Gray
norman@astro.gla.ac.uk
https://nxg.me.uk
@RELEASEDATE@