【原创】Invalid DTD public ID

如果你用移动的变态网址来测试wml,仍然可能失败,比如:
浏览器打开http://211.136.165.53/tt.jsp [^] 密码:cmv2oo9
你会得到如下错误:
【原创】Invalid DTD public ID
不要紧,这个是这个网站的dtd不规范的原因,移动把网页第一行的dtd写成了小写,所以,你可以去查找Invalid DTD Public ID出现的位置。经过查找,发现是在:
external/webkit/webcore/dom/XMLTokenizerLibxml2.cpp下面的internalSubset()方法中的:
#if ENABLE(WML)
        if (isWMLDocument()
            && extId != "-//WAPFORUM//DTD WML 1.3//EN"
            && extId != "-//WAPFORUM//DTD WML 1.2//EN"
            && extId != "-//WAPFORUM//DTD WML 1.1//EN"
            && extId != "-//WAPFORUM//DTD WML 1.0//EN")
            handleError(fatal, "Invalid DTD Public ID", lineNumber(), columnNumber());
#endif
这里按照规范只处理了大写,因此我们应该把出过来的extId转成大写:
#if ENABLE(WML)
          extId = extId.upper();
        if (isWMLDocument()
            && extId != "-//WAPFORUM//DTD WML 1.3//EN"
            && extId != "-//WAPFORUM//DTD WML 1.2//EN"
            && extId != "-//WAPFORUM//DTD WML 1.1//EN"
            && extId != "-//WAPFORUM//DTD WML 1.0//EN")
            handleError(fatal, "Invalid DTD Public ID", lineNumber(), columnNumber());
#endif
这样就ok了。
注意:如果编译的时候出现
external/webkit/WebCore/page/Console.cpp: In member function 'WebCore::String WebCore::Console::lastWMLErrorMessage() const':
external/webkit/WebCore/page/Console.cpp:296: error: 'class WebCore::Page' has no member named 'inspectorController'
时,需要去更改external/webkit/webcore/page/Console.cpp中lastWMLErrorMessage()方法:
#if ENABLE(WML)
String Console::lastWMLErrorMessage() const
{
    Page* page = this->page();
    if (!page)
        return String();
    
//   const Vector<ConsoleMessage*>& consoleMessages = page->inspectorController()->consoleMessages();
//   if (consoleMessages.isEmpty())
  //      return String();

//   Vector<ConsoleMessage*>::const_iterator it = consoleMessages.begin();
//   const Vector<ConsoleMessage*>::const_iterator end = consoleMessages.end();

//    for (; it != end; ++it) {
//       ConsoleMessage* message = *it;
//       if (message->source() != WMLMessageSource)
//           continue;

//       return message->message();
  //  }

    return String();
}
#endif
webkit jni 层在extenal/webkit/webkit/android 目录
参考:
http://blog.csdn.net/hxwwf/article/details/7344280
http://seya.iteye.com/blog/931289
http://blog.csdn.net/weiyouyin/article/details/5739659
http://blog.csdn.net/perfectpdl/article/details/7073786

你可能感兴趣的:(Invalid)