public class RDFXMLParser extends XMLReaderBasedParser implements ErrorHandler
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:
// 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");
ValueFactory,
RDFHandler,
ParseErrorListener,
ParseLocationListenerRDFParser.DatatypeHandlingrdfHandler, valueFactory| Constructor and Description |
|---|
RDFXMLParser()
Creates a new RDFXMLParser that will use a
SimpleValueFactory to create RDF model objects. |
RDFXMLParser(ValueFactory valueFactory)
Creates a new RDFXMLParser that will use the supplied ValueFactory to create RDF model objects.
|
| Modifier and Type | Method and Description |
|---|---|
protected Literal |
createLiteral(String label,
String lang,
IRI datatype) |
protected Resource |
createNode(String nodeID) |
void |
error(SAXParseException exception)
Implementation of SAX ErrorHandler.error
|
void |
fatalError(SAXParseException exception)
Implementation of SAX ErrorHandler.fatalError
|
boolean |
getParseStandAloneDocuments()
Returns whether the parser is currently in a mode to parse stand-alone RDF documents.
|
RDFFormat |
getRDFFormat() |
SAXResult |
getSAXResult(String baseURI) |
Collection<RioSetting<?>> |
getSupportedSettings() |
void |
parse(InputStream in,
String baseURI)
Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI
references.
|
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(Exception e,
RioSetting<Boolean> setting)
Overrides
AbstractRDFParser.reportError(String, RioSetting), adding line- and column number
information to the error. |
protected void |
reportError(String msg,
RioSetting<Boolean> setting)
Overrides
AbstractRDFParser.reportError(String, RioSetting), adding line- and column number
information to the error. |
protected void |
reportFatalError(Exception e)
Overrides
AbstractRDFParser.reportFatalError(Exception), adding line- and column number
information to the error. |
protected void |
reportFatalError(String msg)
Overrides
AbstractRDFParser.reportFatalError(String), adding line- and column number information
to the error. |
protected void |
reportWarning(String msg)
Overrides
AbstractRDFParser.reportWarning(String), adding line- and column number information to
the error. |
protected void |
setBaseURI(ParsedURI baseURI) |
protected void |
setBaseURI(String baseURI) |
void |
setParseStandAloneDocuments(boolean standAloneDocs)
Sets the parser in a mode to parse stand-alone RDF documents.
|
void |
warning(SAXParseException exception)
Implementation of SAX ErrorHandler.warning
|
getCompulsoryXmlFeatureSettings, getCompulsoryXmlPropertySettings, getOptionalXmlFeatureSettings, getOptionalXmlPropertySettings, getXMLReaderclear, clearBNodeIDMap, createBNode, createBNode, createLiteral, createNode, createStatement, createStatement, createURI, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, set, setDatatypeHandling, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setStopAtFirstError, setValueFactory, setVerifyData, stopAtFirstError, verifyDatapublic RDFXMLParser()
SimpleValueFactory to create RDF model objects.public RDFXMLParser(ValueFactory valueFactory)
valueFactory - A ValueFactory.public final RDFFormat getRDFFormat()
getRDFFormat in interface RDFParserpublic void setParseStandAloneDocuments(boolean standAloneDocs)
public boolean getParseStandAloneDocuments()
setParseStandAloneDocuments(boolean)public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException
parse in interface RDFParserin - The InputStream from which to read the data, must not be null.baseURI - The URI associated with the data in the InputStream, must not be null.IOException - If an I/O error occurred while data was read from the InputStream.RDFParseException - If the parser has found an unrecoverable parse error.RDFHandlerException - If the configured statement handler encountered an unrecoverable error.IllegalArgumentException - If the supplied input stream or base URI is null.public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException
parse in interface RDFParserreader - The Reader from which to read the data, must not be null.baseURI - The URI associated with the data in the InputStream, must not be null.IOException - If an I/O error occurred while data was read from the InputStream.RDFParseException - If the parser has found an unrecoverable parse error.RDFHandlerException - If the configured statement handler has encountered an unrecoverable error.IllegalArgumentException - If the supplied reader or base URI is null.public Collection<RioSetting<?>> getSupportedSettings()
getSupportedSettings in interface RDFParsergetSupportedSettings in class AbstractRDFParserprotected void setBaseURI(ParsedURI baseURI)
setBaseURI in class AbstractRDFParserprotected void setBaseURI(String baseURI)
setBaseURI in class AbstractRDFParserprotected Resource createNode(String nodeID) throws RDFParseException
createNode in class AbstractRDFParserRDFParseExceptionprotected Literal createLiteral(String label, String lang, IRI datatype) throws RDFParseException
createLiteral in class AbstractRDFParserRDFParseExceptionprotected void reportWarning(String msg)
AbstractRDFParser.reportWarning(String), adding line- and column number information to
the error.reportWarning in class AbstractRDFParserprotected void reportError(String msg, RioSetting<Boolean> setting) throws RDFParseException
AbstractRDFParser.reportError(String, RioSetting), adding line- and column number
information to the error.reportError in class AbstractRDFParserRDFParseExceptionprotected void reportError(Exception e, RioSetting<Boolean> setting) throws RDFParseException
AbstractRDFParser.reportError(String, RioSetting), adding line- and column number
information to the error.reportError in class AbstractRDFParserRDFParseExceptionprotected void reportFatalError(String msg) throws RDFParseException
AbstractRDFParser.reportFatalError(String), adding line- and column number information
to the error.reportFatalError in class AbstractRDFParserRDFParseExceptionprotected void reportFatalError(Exception e) throws RDFParseException
AbstractRDFParser.reportFatalError(Exception), adding line- and column number
information to the error.reportFatalError in class AbstractRDFParserRDFParseExceptionpublic void warning(SAXParseException exception) throws SAXException
warning in interface ErrorHandlerSAXExceptionpublic void error(SAXParseException exception) throws SAXException
error in interface ErrorHandlerSAXExceptionpublic void fatalError(SAXParseException exception) throws SAXException
fatalError in interface ErrorHandlerSAXExceptionCopyright © 2015-2019 Eclipse Foundation. All Rights Reserved.