| java.lang.Object org.openrdf.rio.helpers.RDFParserBase org.openrdf.rio.rdfxml.RDFXMLParser
RDFXMLParser | public class RDFXMLParser extends RDFParserBase (Code) | | 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");
See Also: org.openrdf.model.ValueFactory See Also: org.openrdf.rio.RDFHandler See Also: org.openrdf.rio.ParseErrorListener See Also: org.openrdf.rio.ParseLocationListener author: Arjohn Kampman |
Inner Class :static class NodeElement | |
Inner Class :static class PropertyElement | |
Constructor Summary | |
public | RDFXMLParser() Creates a new RDFXMLParser that will use a
ValueFactoryImpl to
create RDF model objects. | public | RDFXMLParser(ValueFactory valueFactory) Creates a new RDFXMLParser that will use the supplied
ValueFactory to create RDF model objects. |
Method Summary | |
protected BNode | createBNode(String nodeID) | void | emptyElement(String namespaceURI, String localName, String qName, Atts atts) | void | endElement(String namespaceURI, String localName, String qName) | public boolean | getParseStandAloneDocuments() Returns whether the parser is currently in a mode to parse stand-alone RDF
documents. | final public RDFFormat | getRDFFormat() | public synchronized void | parse(InputStream in, String baseURI) Parses the data from the supplied InputStream, using the supplied baseURI
to resolve any relative URI references. | public synchronized void | parse(Reader reader, String baseURI) Parses the data from the supplied Reader, using the supplied baseURI to
resolve any relative URI references. | protected void | reportError(String msg) Overrides
RDFParserBase.reportError(String) , adding line- and
column number information to the error. | protected void | reportFatalError(String msg) Overrides
RDFParserBase.reportFatalError(String) , adding line-
and column number information to the error. | protected void | reportFatalError(Exception e) Overrides
RDFParserBase.reportFatalError(Exception) , adding line-
and column number information to the error. | protected void | reportWarning(String msg) Overrides
RDFParserBase.reportWarning(String) , adding line- and
column number information to the error. | protected void | setBaseURI(ParsedURI baseURI) | public void | setParseStandAloneDocuments(boolean standAloneDocs) Sets the parser in a mode to parse stand-alone RDF documents. | void | setXMLLang(String xmlLang) | void | startElement(String namespaceURI, String localName, String qName, Atts atts) | void | text(String text) |
RDFXMLParser | public RDFXMLParser()(Code) | | Creates a new RDFXMLParser that will use a
ValueFactoryImpl to
create RDF model objects.
|
RDFXMLParser | public RDFXMLParser(ValueFactory valueFactory)(Code) | | Creates a new RDFXMLParser that will use the supplied
ValueFactory to create RDF model objects.
Parameters: valueFactory - A ValueFactory. |
parse | public synchronized void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException(Code) | | Parses the data from the supplied InputStream, using the supplied baseURI
to resolve any relative URI references.
Parameters: in - The InputStream from which to read the data, must not benull. Parameters: baseURI - The URI associated with the data in the InputStream, must not benull. throws: IOException - If an I/O error occurred while data was read from the InputStream. throws: RDFParseException - If the parser has found an unrecoverable parse error. throws: RDFHandlerException - If the configured statement handler encountered an unrecoverableerror. throws: IllegalArgumentException - If the supplied input stream or base URI is null. |
parse | public synchronized void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException(Code) | | Parses the data from the supplied Reader, using the supplied baseURI to
resolve any relative URI references.
Parameters: reader - The Reader from which to read the data, must not be null. Parameters: baseURI - The URI associated with the data in the InputStream, must not benull. throws: IOException - If an I/O error occurred while data was read from the InputStream. throws: RDFParseException - If the parser has found an unrecoverable parse error. throws: RDFHandlerException - If the configured statement handler has encountered anunrecoverable error. throws: IllegalArgumentException - If the supplied reader or base URI is null. |
setBaseURI | protected void setBaseURI(ParsedURI baseURI)(Code) | | |
setParseStandAloneDocuments | public void setParseStandAloneDocuments(boolean standAloneDocs)(Code) | | Sets the parser in a mode to parse stand-alone RDF documents. In
stand-alone RDF documents, the enclosing rdf:RDF root element
is optional if this root element contains just one element (e.g.
rdf:Description.
|
Methods inherited from org.openrdf.rio.helpers.RDFParserBase | protected void clear()(Code)(Java Doc) protected void clearBNodeIDMap()(Code)(Java Doc) protected BNode createBNode() throws RDFParseException(Code)(Java Doc) protected BNode createBNode(String nodeID) throws RDFParseException(Code)(Java Doc) protected Literal createLiteral(String label, String lang, URI datatype) throws RDFParseException(Code)(Java Doc) protected Statement createStatement(Resource subj, URI pred, Value obj) throws RDFParseException(Code)(Java Doc) protected Statement createStatement(Resource subj, URI pred, Value obj, Resource context) throws RDFParseException(Code)(Java Doc) protected URI createURI(String uri) throws RDFParseException(Code)(Java Doc) public DatatypeHandling datatypeHandling()(Code)(Java Doc) protected String getNamespace(String prefix)(Code)(Java Doc) public ParseErrorListener getParseErrorListener()(Code)(Java Doc) public ParseLocationListener getParseLocationListener()(Code)(Java Doc) public RDFHandler getRDFHandler()(Code)(Java Doc) public boolean preserveBNodeIDs()(Code)(Java Doc) protected void reportError(String msg) throws RDFParseException(Code)(Java Doc) protected void reportError(String msg, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(String msg) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(String msg, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(Exception e) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(Exception e, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportLocation(int lineNo, int columnNo)(Code)(Java Doc) protected void reportWarning(String msg)(Code)(Java Doc) protected void reportWarning(String msg, int lineNo, int columnNo)(Code)(Java Doc) protected URI resolveURI(String uriSpec) throws RDFParseException(Code)(Java Doc) protected void setBaseURI(String uriSpec)(Code)(Java Doc) protected void setBaseURI(ParsedURI baseURI)(Code)(Java Doc) public void setDatatypeHandling(DatatypeHandling datatypeHandling)(Code)(Java Doc) protected void setNamespace(String prefix, String namespace)(Code)(Java Doc) public void setParseErrorListener(ParseErrorListener el)(Code)(Java Doc) public void setParseLocationListener(ParseLocationListener el)(Code)(Java Doc) public void setPreserveBNodeIDs(boolean preserveBNodeIDs)(Code)(Java Doc) public void setRDFHandler(RDFHandler handler)(Code)(Java Doc) public void setStopAtFirstError(boolean stopAtFirstError)(Code)(Java Doc) public void setValueFactory(ValueFactory valueFactory)(Code)(Java Doc) public void setVerifyData(boolean verifyData)(Code)(Java Doc) public boolean stopAtFirstError()(Code)(Java Doc) public boolean verifyData()(Code)(Java Doc)
|
|
|