public class RDFXMLParser extends RDFParserBase 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
,
ParseLocationListener
RDFParser.DatatypeHandling
rdfHandler, valueFactory
Constructor and Description |
---|
RDFXMLParser()
Creates a new RDFXMLParser that will use a
ValueFactoryImpl 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 BNode |
createBNode(String nodeID)
Creates a
BNode object for the specified identifier. |
protected Literal |
createLiteral(String label,
String lang,
URI datatype)
Creates a
Literal object with the supplied parameters. |
void |
error(SAXParseException exception)
Implementation of SAX ErrorHandler.error
|
void |
fatalError(SAXParseException exception)
Implementation of SAX ErrorHandler.fatalError
|
Collection<RioSetting<Boolean>> |
getCompulsoryXmlFeatureSettings()
Returns a collection of settings that will always be set as XML parser
features using
XMLReader.setFeature(String, boolean) . |
Collection<RioSetting<?>> |
getCompulsoryXmlPropertySettings()
Returns a collection of settings that will always be set as XML parser
properties using
XMLReader.setProperty(String, Object) |
Collection<RioSetting<Boolean>> |
getOptionalXmlFeatureSettings()
Returns a collection of settings that will be used, if set in
RDFParserBase.getParserConfig() , as XML parser features using
XMLReader.setFeature(String, boolean) . |
Collection<RioSetting<?>> |
getOptionalXmlPropertySettings()
Returns a collection of settings that will be used, if set in
RDFParserBase.getParserConfig() , as XML parser properties using
XMLReader.setProperty(String, Object) |
boolean |
getParseStandAloneDocuments()
Returns whether the parser is currently in a mode to parse stand-alone RDF
documents.
|
RDFFormat |
getRDFFormat()
Gets the RDF format that this parser can parse.
|
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(String msg,
RioSetting<Boolean> setting)
Overrides
RDFParserBase.reportError(String, RioSetting) , 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 |
reportFatalError(String msg)
Overrides
RDFParserBase.reportFatalError(String) , 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)
Sets the base URI for resolving relative URIs.
|
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
|
clear, clearBNodeIDMap, createBNode, createLiteral, createStatement, createStatement, createURI, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, setBaseURI, setDatatypeHandling, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setStopAtFirstError, setValueFactory, setVerifyData, stopAtFirstError, verifyData
public RDFXMLParser()
ValueFactoryImpl
to
create RDF model objects.public RDFXMLParser(ValueFactory valueFactory)
valueFactory
- A ValueFactory.public final RDFFormat getRDFFormat()
RDFParser
getRDFFormat
in interface RDFParser
public void setParseStandAloneDocuments(boolean standAloneDocs)
public boolean getParseStandAloneDocuments()
setParseStandAloneDocuments(boolean)
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException
parse
in interface RDFParser
in
- 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 RDFParser
reader
- 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<?>> getCompulsoryXmlPropertySettings()
XMLReader.setProperty(String, Object)
Subclasses can override this to specify more supported settings.
RioSetting
s that indicate which properties
will always be setup using
XMLReader.setProperty(String, Object)
.public Collection<RioSetting<Boolean>> getCompulsoryXmlFeatureSettings()
XMLReader.setFeature(String, boolean)
.
Subclasses can override this to specify more supported settings.
RioSetting
s that indicate which boolean
settings will always be setup using
XMLReader.setFeature(String, boolean)
.public Collection<RioSetting<?>> getOptionalXmlPropertySettings()
RDFParserBase.getParserConfig()
, as XML parser properties using
XMLReader.setProperty(String, Object)
Subclasses can override this to specify more supported settings.
RioSetting
s that indicate which properties
can be setup using XMLReader.setProperty(String, Object)
.public Collection<RioSetting<Boolean>> getOptionalXmlFeatureSettings()
RDFParserBase.getParserConfig()
, as XML parser features using
XMLReader.setFeature(String, boolean)
.
Subclasses can override this to specify more supported settings.
RioSetting
s that indicate which boolean
settings can be setup using
XMLReader.setFeature(String, boolean)
.public Collection<RioSetting<?>> getSupportedSettings()
getSupportedSettings
in interface RDFParser
getSupportedSettings
in class RDFParserBase
RioSetting
s that are supported by this
RDFParser.protected void setBaseURI(ParsedURI baseURI)
RDFParserBase
setBaseURI
in class RDFParserBase
protected BNode createBNode(String nodeID) throws RDFParseException
RDFParserBase
BNode
object for the specified identifier.createBNode
in class RDFParserBase
RDFParseException
protected Literal createLiteral(String label, String lang, URI datatype) throws RDFParseException
RDFParserBase
Literal
object with the supplied parameters.createLiteral
in class RDFParserBase
RDFParseException
protected void reportWarning(String msg)
RDFParserBase.reportWarning(String)
, adding line- and
column number information to the error.reportWarning
in class RDFParserBase
protected void reportError(String msg, RioSetting<Boolean> setting) throws RDFParseException
RDFParserBase.reportError(String, RioSetting)
, adding
line- and column number information to the error.reportError
in class RDFParserBase
msg
- The message to use for
ParseErrorListener.error(String, int, int)
and for
RDFParseException.RDFParseException(String, int, int)
.setting
- The boolean setting that will be checked to determine if this is an
issue that we need to look at at all. If this setting is true, then
the error listener will receive the error, and if
ParserConfig.isNonFatalError(RioSetting)
returns true an
exception will be thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for
the given setting.protected void reportFatalError(String msg) throws RDFParseException
RDFParserBase.reportFatalError(String)
, adding line- and
column number information to the error.reportFatalError
in class RDFParserBase
RDFParseException
protected void reportFatalError(Exception e) throws RDFParseException
RDFParserBase.reportFatalError(Exception)
, adding line-
and column number information to the error.reportFatalError
in class RDFParserBase
RDFParseException
public void warning(SAXParseException exception) throws SAXException
warning
in interface ErrorHandler
SAXException
public void error(SAXParseException exception) throws SAXException
error
in interface ErrorHandler
SAXException
public void fatalError(SAXParseException exception) throws SAXException
fatalError
in interface ErrorHandler
SAXException
Copyright © 2001-2016 Aduna. All Rights Reserved.