我编写了一个程序,它读取一堆XML文件,然后对它们进行比较。此程序的工作方式类似于XML Version 1.0
的宝石,但它会突破XML version 1.1
以下的异常。有人可以帮忙吗?
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl.scanStartElement(XML11NSDocumentScannerImpl.java:351)
at com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl$NS11ContentDriver.scanRootElementHook(XML11NSDocumentScannerImpl.java:889)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3104)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl.next(XML11NSDocumentScannerImpl.java:852)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:554)
我知道有类似的问题here。我已经下载了xercesImpl.jar:xml-apis.jar
并尝试了但我仍然得到了同样的例外。我已经下载了下图中突出显示的拉链。
编辑1:发布XML文件。(已编辑XML以隐藏客户特定的详细信息)
<?xml version="1.1" encoding="UTF-8"?>
<!-- file filenamehere -->
<jnlp codebase="http://servername here/" href="http://servername/foldername/filename">
<information>
<title>something</title>
<vendor>vernor info</vendor>
<icon href="image here"/>
<icon kind="something" href="impage here"/>
</information>
<security> <all-permissions/> </security>
<resources>
<j2se version="1.5+" initial-heap-size="128m" max-heap-size="512m" java-vm-args="-XX:PermSize=64m -Djava.lang.Integer.IntegerCache.high=30000"/>
<jar href="1.jar"/>
<jar href="2.jar"/>
<jar href="3.jar"/>
<jar href="4.jar"/>
<jar href="5.jar"/>
<jar href="6.jar" main="true"/>
<jar href="7.jar"/>
<jar href="8.jar"/>
<jar href="9.jar"/>
<jar href="0.jar"/>
<jar href="22.jar"/>
<jar href="11.jar"/>
<jar href="33.jar"/>
<jar href="44.jar"/>
<jar href="55.jar"/>
<jar href="66.jar"/>
<jar href="77.jar"/>
<jar href="88.jar"/>
<jar href="99.jar"/>
<jar href="00.jar"/>
<jar href="12.jar"/>
<jar href="23.jar"/>
<jar href="34.jar"/>
<jar href="45.jar"/>
<jar href="56.jar"/>
<jar href="67.jar"/>
<jar href="78.jar"/>
<jar href="89.jar"/>
<jar href="90.jar"/>
<jar href="13.jar"/>
<jar href="14.jar"/>
<jar href="15.jar"/>
<jar href="16.jar"/>
<jar href="17.jar"/>
<jar href="18.jar"/>
<jar href="19.jar"/>
<jar href="24.jar"/>
<jar href="25.jar"/>
<jar href="26.jar"/>
<jar href="27.jar"/>
<jar href="28.jar"/>
<jar href="29.jar"/>
<jar href="30.jar"/>
<property name="org.apache.commons.logging.Log" value="org.apache.commons.logging.impl.Log4JLogger"/>
<property name="someproperty3343" value="some name"/>
<property name="log4j.configuration" value="resources/properties/something.properties"/>
<property name="someproperty" value="true"/>
<property name="swing.noxp" value="true"/>
<property name="someproperty1" value="true"/>
<property name="ssomeproperty2" value="false"/>
<property name="someproperty3" value="true"/>
<property name="someproperty4" value="true"/>
<property name="ui.jws.useJWSPath" value="true"/>
<property name="ui.jws.jwspath" value="javaws.exe"/>
<property name="someproperty6" value="1"/>
<property name="someproperty656" value="true"/>
<property name="someproperty7" value="Frame"/>
<property name="someproperty78" value="true"/>
<property name="someproperty6B" value="true"/>
<property name="ui.jnlpfilename" value="1.5/some.jnlp"/>
<property name="ui.products.cdswap.setNYTimeZone" value="false"/>
<property name="somepropertyttg" value="http://servername/foldername/ChainSaw.jnlp"/>
<property name="someproperty89" value="false"/>
<property name="98" value="http://servername/something/services/services"/>
<property name="someproperty76" value="-1"/>
<property name="someproperty54" value="http://server/Service.asmx"/>
</resources>
<resources os="Windows">
<nativelib href="lib/winops.jar"/>
</resources>
<application-desc main-class="com.main.mainclass">
<argument>-R</argument>
<argument>parameter1</argument>
<argument>-P</argument>
<argument>parameter3</argument>
<argument>-l</argument>
<argument>windows</argument>
<argument>-co</argument>
<argument>parameter4</argument>
</application-desc>
</jnlp>
编辑2:道歉......我正在使用XMLEventReader ..最初标题是Stax。