我想與SAXReader 離線一起工作,問題是SAXReader正在驗證DTD的xml聲明。我不想更改DTD或XML中的其他任何內容。從本網站和其他來源上搜索,我發現2個答案是沒有幫助我:如何使用dom4j SAXReader離線?
- 使用的EntityResolver繞過網絡呼叫
- 使用setIncludeExternalDTDDeclarations(假)的
例什麼我試圖做的:
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">
我仍然無法脫機工作,請指教...謝謝
堆棧跟蹤:
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
你在找什麼錯誤?它會拋出任何異常嗎?你能發佈這種異常的消息和堆棧跟蹤嗎? – 2012-01-12 08:36:17