关于xml解析器

今天看了javaeye上的关于xml的文章,才明白了一些东西。
http://forum.javaeye.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]

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