关于xml解析器

今天看了javaeye上的关于xml的文章,才明白了一些东西。
http://forum.iteye.com/viewtopic.php?t=75&postdays=0&postorder=asc&start=0

JAXP是sun jdk中提供的xml操作的标准接口,jaxp遵循w3c的dom标准,通过jaxp编写的代码,可以使用不同的xml解析器实现,但jdk1.4默认包括一种解析器Crimson,在rt.jar中可以找到org.apache.crimson包。如果需要使用别的xml解析器,需要专门配置。

以下来自: http://dev.csdn.net/develop/article/61/article/54/54381.shtm

1. 系统属性javax.xml.parsers.DocumentBuilderFactoryjavax.xml.parsers.SAXParserFactory

2. jdk-dir/lib/jaxp.properties中设定的javax.xml.parsers.DocumentBuilderFactoryjavax.xml.parsers.SAXParserFactory属性

3. 运行时jar包中META-INF/services/javax.xml.parsers.DocumentBuilderFactoryjavax.xml.parsers.SAXParserFactory文件中设定的值

4. 如果上面的解析器都没有找到,则使用Crimson。如果还没有。。。。。。那只能ClassNotFound了。

经过测试,在jdk1.4中果然是这样的,向robbin说的一样,打开jvm的-verbose参数,可以看到默认情况下载入的类是
[java] [Loaded org.jdom.ContentList]
[java] [Loaded java.lang.CloneNotSupportedException from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded java.lang.IndexOutOfBoundsException from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded org.jdom.input.JAXPParserFactory]
[java] [Loaded javax.xml.parsers.ParserConfigurationException from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.SAXParserFactory from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.FactoryFinder from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.FactoryFinder$ClassLoaderFinder from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.FactoryFinder$ClassLoaderFinderConcrete from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded org.apache.crimson.jaxp.SAXParserFactoryImpl from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.SAXParser from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded org.apache.crimson.jaxp.SAXParserImpl from D:\jdk1.4\jre\lib\rt.jar]
[java] [Loaded org.apache.crimson.parser.XMLReaderImpl from D:\jdk1.4\jre\lib\rt.jar]
打开rt.jar是可以找到这些class的。
对jdk5。0也做了同样的测试,发现jdk5.0默认使用的是xerces了,org.apache.xerces放到了com.sun包里了,记得javasearch上有篇文章专门讲过jdk中的sun包是不公开的。
[java] [Loaded javax.xml.parsers.ParserConfigurationException from shared objects file]
[java] [Loaded javax.xml.parsers.SAXParserFactory from shared objects file]
[java] [Loaded javax.xml.parsers.FactoryFinder from shared objects file]
[java] [Loaded javax.xml.parsers.SecuritySupport from shared objects file]
[java] [Loaded javax.xml.parsers.SecuritySupport$2 from shared objects file]
[java] [Loaded javax.xml.parsers.SecuritySupport$1 from shared objects file]
[java] [Loaded javax.xml.parsers.SecuritySupport$5 from shared objects file]
[java] [Loaded javax.xml.parsers.SecuritySupport$4 from shared objects file]
[java] [Loaded com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl from D:\jdk1.5\jre\lib\rt.jar]
[java] [Loaded com.sun.org.apache.xerces.internal.jaxp.JAXPConstants from D:\jdk1.5\jre\lib\rt.jar]
[java] [Loaded javax.xml.parsers.SAXParser from shared objects file]
[java] [Loaded com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl from D:\jdk1.5\jre\lib\rt.jar]
[java] [Loaded com.sun.org.apache.xerces.internal.util.SecurityManager from D:\jdk1.5\jre\lib\rt.jar]
[java] [Loaded com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager from D:\jdk1.5\jre\lib\rt.jar]

<!-- google_ad_client = "pub-9232855773311077"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_channel =""; //--> <iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-9232855773311077&amp;dt=1110259223642&amp;format=336x280_as&amp;output=html&amp;u_h=768&amp;u_w=1024&amp;u_ah=738&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;u_his=23&amp;u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="65535"></iframe>

你可能感兴趣的:(java,apache,xml,Google,sun)