Я хотел бы работать с SAXReader офлайн , проблема в том, что SAXReader проверяет XML, соответствующий DTD. Я не хочу менять DTD или что-то еще в XML. В результате поиска на этом веб-сайте и в других источниках я нашел 2 ответа, которые не помогли мне:
- используйте EntityResolver для обхода сетевого вызова
- использовать setIncludeExternalDTDDeclarations (false)
Пример того, что я пытался сделать:
protected Document getPlistDocument() throws MalformedURLException,
DocumentException {
SAXReader saxReader = new SAXReader();
saxReader.setIgnoreComments(false);
saxReader.setIncludeExternalDTDDeclarations(false);
saxReader.setIncludeInternalDTDDeclarations(true);
saxReader.setEntityResolver(new MyResolver());
Document plistDocument = saxReader.read(getDestinationFile().toURI().toURL());
return plistDocument;
}
public class MyResolver implements EntityResolver {
public InputSource resolveEntity (String publicId, String systemId)
{
if (systemId.equals("http://www.myhost.com/today")) {
// if we want a custom implementation, return a special input source
return null;
} else {
// use the default behaviour
return null;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
Я все еще не могу работать в автономном режиме, пожалуйста, совет ... спасибо
StackTrace:
14:20:44,358 ERROR [ApplicationBuilder] iphone build failed: Resource Manager - Problem handle Root.plist: www.apple.com Nested exception: www.apple.com
com.something.builder.sourcemanager.exception.SourceHandlingException: Resource Manager - Problem handle Root.plist: www.apple.com Nested exception: www.apple.com
****
****
Caused by: org.dom4j.DocumentException: www.apple.com Nested exception: www.apple.com
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:291)
... 10 more