Package org.openpreservation.format.xml
Class XmlParser
java.lang.Object
org.openpreservation.format.xml.XmlParser
Class to wrap the checking of XML files for well-formedness and validity.
- Author:
- Carl Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final SAXParserFactory
Convenience method to obtain a pre-configured SAXParserFactory that is not validating and is namespace aware.parse
(InputStream toTest) Parses the suppliedInputStream
for well-formedness and returns aParseResult
object.Parses the suppliedPath
for well-formedness and returns aParseResult
object.
-
Constructor Details
-
XmlParser
Default constructor for theXmlParser
class.- Throws:
ParserConfigurationException
- if the parser can not be configuredSAXException
- if the parser can not be created
-
-
Method Details
-
getNonValidatingFactory
public static final SAXParserFactory getNonValidatingFactory() throws SAXNotRecognizedException, SAXNotSupportedException, ParserConfigurationExceptionConvenience method to obtain a pre-configured SAXParserFactory that is not validating and is namespace aware.- Returns:
- a pre-configured
SAXParserFactory
that is not validating and is namespace aware. - Throws:
SAXNotRecognizedException
- When the underlying XMLReader does not recognize the property name.SAXNotSupportedException
- When the underlying XMLReader recognizes the property name but doesn't support the property.ParserConfigurationException
- When the underlying XMLReader is not configured correctly.
-
parse
Parses the suppliedInputStream
for well-formedness and returns aParseResult
object.- Parameters:
toTest
- anInputStream
to be parsed.- Returns:
- a
ParseResult
object containing the result of the parse. - Throws:
IOException
- if the suppliedInputStream
can not be read.
-
parse
Parses the suppliedPath
for well-formedness and returns aParseResult
object.- Parameters:
toTest
- aPath
to be parsed.- Returns:
- a
ParseResult
object containing the result of the parse. - Throws:
IOException
- if the suppliedPath
can not be read.
-