У меня проблема с синтаксическим анализом старого XML-файла с DocumentBuilder, когда он создает исключение IOException. Это XML:
<?xml version="1.0" encoding="UTF-8"?>
<pnml>
<net id="Net-One" type="P/T net">
<place id="P0">
<graphics>
<position x="45.0" y="30.0" />
</graphics>
<name>
<value>p0</value>
<graphics>
<offset x="0.0" y="5.0" />
</graphics>
</name>
<initialMarking>
<value>1</value>
<graphics>
<offset x="0.0" y="0.0" />
</graphics>
</initialMarking>
<capacity>
<value>0</value>
</capacity>
<invariant>
<value><inf</value>
</invariant>
</place>
<place id="P1">
<graphics>
<position x="45.0" y="105.0" />
</graphics>
<name>
<value>p1</value>
<graphics>
<offset x="3.0" y="5.0" />
</graphics>
</name>
<initialMarking>
<value>1</value>
<graphics>
<offset x="0.0" y="0.0" />
</graphics>
</initialMarking>
<capacity>
<value>0</value>
</capacity>
<invariant>
<value><inf</value>
</invariant>
</place>
<place id="P2">
<graphics>
<position x="45.0" y="180.0" />
</graphics>
<name>
<value>p2</value>
<graphics>
<offset x="2.0" y="6.0" />
</graphics>
</name>
<initialMarking>
<value>1</value>
<graphics>
<offset x="0.0" y="0.0" />
</graphics>
</initialMarking>
<capacity>
<value>0</value>
</capacity>
<invariant>
<value><inf</value>
</invariant>
</place>
<place id="P3">
<graphics>
<position x="330.0" y="30.0" />
</graphics>
<name>
<value>p3</value>
<graphics>
<offset x="38.0" y="5.0" />
</graphics>
</name>
<initialMarking>
<value>0</value>
<graphics>
<offset x="0.0" y="0.0" />
</graphics>
</initialMarking>
<capacity>
<value>0</value>
</capacity>
<invariant>
<value><inf</value>
</invariant>
</place>
<place id="P4">
<graphics>
<position x="330.0" y="120.0" />
</graphics>
<name>
<value>p4</value>
<graphics>
<offset x="48.0" y="4.0" />
</graphics>
</name>
<initialMarking>
<value>0</value>
<graphics>
<offset x="0.0" y="0.0" />
</graphics>
</initialMarking>
<capacity>
<value>0</value>
</capacity>
<invariant>
<value><inf</value>
</invariant>
</place>
<transition id="T0">
<graphics>
<position x="165.0" y="30.0" />
</graphics>
<name>
<value>t0</value>
<graphics>
<offset x="5.0" y="39.0" />
</graphics>
</name>
<orientation>
<value>0</value>
</orientation>
<rate>
<value>1.0</value>
</rate>
<timed>
<value>false</value>
</timed>
<infiniteServer>
<value>false</value>
</infiniteServer>
<priority>
<value>1</value>
</priority>
</transition>
<transition id="T1">
<graphics>
<position x="165.0" y="120.0" />
</graphics>
<name>
<value>t1</value>
<graphics>
<offset x="24.0" y="48.0" />
</graphics>
</name>
<orientation>
<value>0</value>
</orientation>
<rate>
<value>1.0</value>
</rate>
<timed>
<value>false</value>
</timed>
<infiniteServer>
<value>false</value>
</infiniteServer>
<priority>
<value>1</value>
</priority>
</transition>
<arc id="P0 to T0" source="P0" target="T0">
<graphics />
<inscription>
<value>[0,inf)</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="71" y="42" curvePoint="false" />
<arcpath id="001" x="171" y="42" curvePoint="false" />
<type value="timed" />
</arc>
<arc id="P1 to T1" source="P1" target="T1">
<graphics />
<inscription>
<value>[0,inf)</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="71" y="118" curvePoint="false" />
<arcpath id="001" x="172" y="127" curvePoint="false" />
<type value="timed" />
</arc>
<arc id="P2 to T1" source="P2" target="T1">
<graphics />
<inscription>
<value>[4,5]</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="70" y="185" curvePoint="false" />
<arcpath id="001" x="171" y="137" curvePoint="false" />
<type value="timed" />
</arc>
<arc id="T0 to P3" source="T0" target="P3">
<graphics />
<inscription>
<value>1</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="182" y="37" curvePoint="false" />
<arcpath id="001" x="327" y="41" curvePoint="false" />
<type value="normal" />
</arc>
<arc id="T0 to P4" source="T0" target="P4">
<graphics />
<inscription>
<value>1</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="181" y="47" curvePoint="false" />
<arcpath id="001" x="328" y="124" curvePoint="false" />
<type value="normal" />
</arc>
<arc id="T1 to P4" source="T1" target="P4">
<graphics />
<inscription>
<value>1</value>
<graphics />
</inscription>
<tagged>
<value>false</value>
</tagged>
<arcpath id="000" x="181" y="132" curvePoint="false" />
<arcpath id="001" x="327" y="132" curvePoint="false" />
<type value="normal" />
</arc>
</net>
</pnml>
Он отлично разбирается в python с minidom ...
Так что мне просто интересно, было ли обновление в построителе документов в Java, которое вызываетэто потерпит неудачу для этого конкретного файла. Кроме того, если есть обходной путь к проблеме или альтернативный способ анализа файлов XML в Java.
Вот трассировка стека:
java.io.IOException: Stream Closed
at java.base/java.io.FileInputStream.read0(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:231)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:3056)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:705)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:150)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:860)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)