jd.xslt - Parser Setup

jd.xslt uses a XML parser to read XML documents. Since the distribution does not contain an own parser implementation you need to provide a parser. This page describes the steps how to setup jd.xslt to use a specific parser.

For now jd.xslt supports these parser types:

Install a parser

If you do not already have a parser you can download one of the following free available parsers. Follow its installation instructions (which will as always add a Java archive to your classpath).

Parser Type Location
Crimson from Apache SAX 2 http://xml.apache.org/crimson/index.html
Note: JDK 1.4 already contains Crimson
Xerces from Apache SAX 2 http://xml.apache.org/xerces-j/index.html
Ælfred from Michael Kay's Saxon SAX 2 http://saxon.sourceforge.net/
Oracle XDK SAX 2 http://technet.oracle.com/tech/xml/xdk_java/content.html
XPP3 from Aleksander Slominski Pull Parser http://www.extreme.indiana.edu/soap/xpp/

If you want to deploy Xerces or Crimson, then you are already done, since jd.xslt automatically recognizes and uses these parsers if not explicitly directed to another parser.

Configure jd.xslt to use a specific parser

There are various ways to tell jd.xslt to use a specific parser. Each of them requires to know the fully qualified name of the parser class. Here is a list of these class names for the parsers mentioned above:

Parser Java Class
Crimson from Apache org.apache.crimson.parser.XMLReaderImpl
Xerces from Apache org.apache.xerces.parsers.SAXParser
Ælfred from Michael Kay's Saxon com.icl.saxon.aelfred.SAXDriver
Oracle XDK oracle.xml.parser.v2.SAXParser
Pull Parser org.xmlpull.mxp1.MXParser

Use command-line options

The command-line interface of jd.xslt accepts the options -parser, -parserxml and -parserxsl which let you specify the parser used to parse the input documents and/or the stylesheet documents. For further details jump to command-line page.

Use a JVM system property

Naturally command-line options are of little use if you invoke jd.xslt directly from your program. In this case just set the JVM system property jd.xml.xpath.model.parser to the desired parser class when starting up the Java virtual machine:
   java -Djd.xml.xpath.model.parser=myxml.MyParser ...
As an alternative in case you are using a SAX 1 or SAX 2 parser you can also set the system property org.xml.sax.driver. The advantage is that its a standard way to configure the default SAX parser class so other programs could use this information too:
   java -Dorg.xml.sax.driver=myxml.sax.MySaxParser ...

Directly provide a parser object

Another way to programmatically direct jd.xslt to a specific parser is to instantiate a parser object in your program and pass it to the stylesheet object.


main page