Piccolo is a non-validating XML parser for Java supporting the
SAX1, SAX2 with extensions 1.0, and JAXP 1.1 SAX parsing specifications.
Piccolo has been tested using the xmlconf
test suite and correctly parses all well-formed documents and
correctly identifies all but one well-formedness error. See the
installation and usage information below for the interface you'll
be using. Documentation on the source
code is also available, as is the javadoc.
JAXP
Installation (choose one)
- Put Piccolo.jar in your $JAVA_HOME/jre/lib/ext directory.
Note: if you have more than one JAXP library installed, you'll
need to add the line
javax.xml.parsers.SAXParserFactory=com.bluecast.xml.JAXPSAXParserFactory
to your $JAVA_HOME/jre/lib/jaxp.properties file.
- Put Piccolo.jar in your classpath before any other
JAXP libraries.
- Put Piccolo.jar anywhere in your classpath and set
the system property as described in step 1 or at run time using
the
-D option.
Piccolo is a non-validating parser, but it will create a validating
parser when requested through JAXP. Piccolo will automatically
search for another JAXP library to create the validating parser.
You can also specify which JAXP factory class to use. If you wish
to use Xerces, for example, put this line in jaxp.properties:
com.bluecast.xml.ValidatingSAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
Usage
import org.xml.sax.*;
import javax.xml.parsers.*;
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(false);
XMLReader xmlReader = factory.newSAXParser().getXMLReader();
xmlReader.setContentHandler(new MyContentHandler());
xmlReader.parse("somexmlfile.xml");
SAX
Installation
For SAX2, set the org.xml.sax.driver system property
to com.bluecast.xml.Piccolo . For SAX1, set org.xml.sax.parser
to com.bluecast.xml.Piccolo .
- Put piccolo.jar in your jre/lib/ext directory.
Note: if you have more than one JAXP parser installed, you'll
need to add the line
javax.xml.parsers.SAXParserFactory
= com.bluecast.xml.JAXPSAXParserFactory to your $JAVA_HOME/jre/lib/jaxp.properties
file.
- Put piccolo.jar in your classpath before any other
JAXP libraries.
- Put piccolo.jar anywhere in your classpath and set
the system property as described in step 1 or at run time using
the
-D option.
Usage (example is for SAX2 extensions 1.0)
import org.xml.sax.*;
import org.xml.sax.ext.*;
import org.xml.sax.helpers.*;
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
// This class also implements the LexicalHandler and DeclHandler
extensions
MyContentHandler myCH = new MyContentHandler();
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler",myCH);
xmlReader.setProperty("http://xml.org/sax/properties/declaration-handler",myCH);
xmlReader.setContentHandler(myCH);
xmlReader.parse("somexmlfile.xml");
XSL
Piccolo itself does not support XSL transformations. XSLT is
usually implemented as a layer that sits on top of an XML parser.
Many XSLT packages will simply use JAXP to create a SAX2 parser
and therefore work well with Piccolo. One such package is SAXON.
To configure SAXON (and many other XSLT packages) to use Piccolo
as the underlying XML parser:
- Copy Piccolo.jar to your $JAVA_HOME/jre/lib/ext.
- Add the line
javax.xml.parsers.SAXParserFactory=com.bluecast.xml.JAXPSAXParserFactory
to your $JAVA_HOME/jre/lib/jaxp.properties file.
|