Class RDFXMLParser

All Implemented Interfaces:
RDFParser, ErrorHandler

public class RDFXMLParser extends XMLReaderBasedParser implements ErrorHandler
A parser for XML-serialized RDF. This parser operates directly on the SAX events generated by a SAX-enabled XML parser. The XML parser should be compliant with SAX2. You should specify which SAX parser should be used by setting the org.xml.sax.driver property. This parser is not thread-safe, therefore it's public methods are synchronized.

To parse a document using this parser:

  • Create an instance of RDFXMLParser, optionally supplying it with your own ValueFactory.
  • Set the RDFHandler.
  • Optionally, set the ParseErrorListener and/or ParseLocationListener.
  • Optionally, specify whether the parser should verify the data it parses and whether it should stop immediately when it finds an error in the data (both default to true).
  • Call the parse method.
Example code:
 // Use the SAX2-compliant Xerces parser:
 System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");

 RDFParser parser = new RDFXMLParser();
 parser.setRDFHandler(myRDFHandler);
 parser.setParseErrorListener(myParseErrorListener);
 parser.setVerifyData(true);
 parser.stopAtFirstError(false);

 // Parse the data from inputStream, resolving any
 // relative URIs against http://foo/bar:
 parser.parse(inputStream, "http://foo/bar");
 

Note that JAXP entity expansion limits may apply. Check the documentation on limits and using the jaxp.properties file if you get one of the following errors:


 JAXP00010001: The parser has encountered more than "64000" entity expansions in this document
 JAXP00010004: The accumulated size of entities is ... that exceeded the "50,000,000" limit
 

As a work-around, try passing -Djdk.xml.totalEntitySizeLimit=0 -DentityExpansionLimit=0 to the JVM.

Author:
Arjohn Kampman
See Also: