English 中文(简体)
• 如何利用四舍五入线?
原标题:how to use dom4j SAXReader offline?

我愿与SAXReader(offline)合作,问题在于SAXReader正在核查与DTD的xml编码。 我不想改变《反歧视法》或其他任何内容。 我通过搜索网站和其他来源,找到了2个答案:did not。 帮助我:

  1. use EntityResolver to bypass the network call
  2. use 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">

页: 1 感谢

<>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
最佳回答

贵实体的决心者不处理任何事项(因为总是回报无效)。 当系统识别系统时,将其投向实际的DTD文档中,因为这个系统把鸡肉下载的DTD。

public class MyResolver implements EntityResolver {
    public InputSource resolveEntity (String publicId, String systemId)
    {
        if (systemId.equals("http://www.apple.com/DTDs/PropertyList-1.0.dtd")) {
            return new InputSource(MyResolver.class.getResourceAsStream("/dtds/PropertyList-1.0.dtd");
        } else {
            // use the default behaviour
            return null;
        }
    }
}

例如,这种执行将DVD从班次中回收(在包装上<编码>dtds)。 你只是要下载TD yourself,并在包件<编码>dtds上打上。

问题回答

Note, too, that you re not actually validating against the DTD. To accomplish that, you need to do:

SAXReader saxReader = new SAXReader(true);

Otherwise JB s right - he got in 3 mins before me!

As an option, if you want to just use SAXReader offline, disable its external DTD fetching via the http://apache.org/xml/features/nonvalidating/load-external-dtd Xerces feature.

According Xerces features documentation, setting this to false makes SAXReader ignore the external DTD completely.

《经济、社会、文化权利国际公约》





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签