}
private OPFData peek(InputStream inputStream)
throws InvalidVersionException
{
OPFDataBuilder builder = new OPFDataBuilder();
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
try
{
factory.setFeature("http://xml.org/sax/features/validation", false);
} catch (Exception ignored)
{
}
SAXParser parser;
try
{
ParserHandler handler = new ParserHandler(builder);
parser = factory.newSAXParser();
parser.getXMLReader().setEntityResolver(handler);
parser.getXMLReader().setErrorHandler(handler);
parser.getXMLReader().setContentHandler(handler);
parser.getXMLReader().parse(new InputSource(inputStream));
} catch (ParserConfigurationException e)
{
report.message(MessageId.RSC_005, new MessageLocation(path, -1, -1),
e.getMessage());
} catch (InvalidVersionException e)
{
throw e;
} catch (SAXException e)
{
if (FINISHED_PARSING.equals(e.getMessage()))
{
OPFData data = builder.build();
return data;
} else
{
report.message(MessageId.RSC_005, new MessageLocation(path, -1, -1),
e.getMessage());