Open mfissehaye opened 7 years ago
Hello,
I came across in unit tests, parsing some xml files was taking too long, because of the validations. So I disabled the validations (related answer). It works perfectly fine in my unit tests; but getting the same exceptions in Sample Application as well. Though it didn't occur to me that the exceptions breaks the operation of the library.
I'll dig in for more info.
Android sdk (api-23) uses this method for setFeature:
`@Override
public void setFeature(String name, boolean value)
throws ParserConfigurationException {
if (name == null) {
throw new NullPointerException("name == null");
}
if (NAMESPACES.equals(name)) {
setNamespaceAware(value);
} else if (VALIDATION.equals(name)) {
setValidating(value);
} else {
throw new ParserConfigurationException(name);
}
}`
As this states, android throws exception for all other features other than namespace and validation.
Same problem here. Get a ParserConfigurationException on reader.setFullContent(epubFilePath). The Exception doesn't break the operation and I can get the ebook content with bookSection.getSectionContent().
I'm getting the same error with the sample app provided EpubParser-Sample-Android-Application.
It looks like Android SDK DocumentBuilderFactory cannot support these two features
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
As these features are used for document validation maybe they are not mandatory ? anyway they are not supported on API 25. docs here and here
I tried to use the library according to the guideline on the GitHub page The first problem I got is that there is no class called Book.
The fifth line of code in the Usage section tries to create a Book object from
reader.readSection
. I thought maybe you meant to sayBookSection
so I replaced it.And further into the code
reader.setFullContent(epubFilePath);
throws the following exception. (I have put the complete stack trace)What I understood while debugging is that the
DocumentBuilderFactoryImpl
class throwsParserConfigurationException
if instance ofDocumentBuilderFactoryImpl
calls setFeature with names different fromhttp://xml.org/sax/features/namespaces
andhttp://xml.org/sax/features/validation
Is there a problem with my android depedencies?