2010-05-16 39 views
0

创建XML文档如果我试图通过这个代码来创建一个Java applet的一个新的XML文档:在Java小程序

http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance()

DocumentBuilderFactory.newInstance(); 

我会得到这个错误:

Java Plug-in 1.6.0_19 
Using JRE version 1.6.0_19-b04 Java HotSpot(TM) Client VM 

javax.xml.parsers.FactoryConfigurationError: Provider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> not found 
     at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) 

我不在乎DTD的。

  1. 它为什么要找它?
  2. 我该怎么样在java applets中创建一个xml文档
  3. 我该如何让它工作?

封闭的html文件看起来是这样的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> 
<head> 
<title>Loading...</title> 
</head> 

Can some comment this thread

The problem was with the entity resolver, which points to the w3c.org web site. The access to the reference DTDs on this site has been restricted for application use. The solution was to implement my own entity resolver.

相关:

  1. http://forums.sun.com/thread.jspa?threadID=515055
  2. org.apache.xerces.jaxp.SAXParserFactoryImpl not found when importing Gears API in GWT
  3. http://java.itags.org/java-desktop/4839/

回答

1

如果你正在做的是呼吁DocumentBuilderFactory.newInstance();那么这应该不会导致错误。您链接到的帖子不相关。

javax.xml.parsers.FactoryConfigurationError: Provider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> not found

这表明一些奇怪的配置错误/缺陷。提供者应该(我认为)是JAXP实现的工厂类名称。检查你是不是在做一些奇怪的事情,比如设置javax.xml.parsers.DocumentBuilderFactory系统属性或者在你的Applet类路径上有一个无效的META-INF/services/javax.xml.parsers.DocumentBuilderFactory文件。