matsim-org/matsim-code-examples

Error occured when validating transitSchedule

1MTW opened this issue · 4 comments

1MTW commented

Hello, I'm trying to validate example transitSchedule file with Gui.
I used transitSchedule.xml from pt-simple.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE transitSchedule SYSTEM "http://www.matsim.org/files/dtd/transitSchedule_v1.dtd">
<transitSchedule>
<transitStops>
<stopFacility id="192" x="05" y="0" linkRefId="1-2"/>
<stopFacility id="293" x="15" y="0" linkRefId="2-3"/>
<stopFacility id="495" x="2005" y="0" linkRefId="4-5"/>
<stopFacility id="596" x="2015" y="0" linkRefId="5-6"/>
</transitStops>
<transitLine id="gelb">
  <transitRoute id="gelb_1">
    <transportMode>pt</transportMode>
    <routeProfile>
      <stop refId="192" departureOffset="00:00:00" arrivalOffset="00:00:00" awaitDeparture="true"/>
      <stop refId="293" departureOffset="00:00:30" arrivalOffset="00:00:30" awaitDeparture="true"/>
      <stop refId="495" departureOffset="00:30:00" arrivalOffset="00:30:00" awaitDeparture="true"/>
      <stop refId="596" departureOffset="00:30:30" arrivalOffset="00:30:30" awaitDeparture="true"/>
	</routeProfile>
    <route>
      <link refId="1-2"/>
      <link refId="2-3"/>
      <link refId="3-4"/>
      <link refId="4-5"/>
      <link refId="5-6"/>
    </route>
    <departures>
      <departure id="1000" departureTime="05:05:00" vehicleRefId="1000"/>
    </departures>
  </transitRoute>
</transitLine>
</transitSchedule>

And these error messages were occured.

XML-FATAL: , line 1, column 1:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
Exception in thread "Thread-0" org.matsim.core.utils.io.UncheckedIOException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
	at org.matsim.core.utils.io.MatsimXmlParser.parse(MatsimXmlParser.java:205)
	at org.matsim.core.utils.io.MatsimXmlParser.readFile(MatsimXmlParser.java:150)
	at org.matsim.run.gui.ScheduleValidatorWindow.lambda$run$4(ScheduleValidatorWindow.java:171)
	at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
	at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
	at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:978)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:114)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
	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.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
	at org.matsim.core.utils.io.MatsimXmlParser.parse(MatsimXmlParser.java:199)
	... 3 more

I searched for this error, and tried a few solutions(check BOM, check nothing exist before the <?xml version="1.0" encoding="UTF-8"?>). But these were not worked.
How can I fix this problem.
Thank you.

This exception indicates that your transit schedule file is not formatted correctly. Could you make the file available please?

1MTW commented

image

1MTW commented

It's an default file from matsim/examples/scenarios/pt-simple.

Thank you for your answer.

I have tried the example by using the following code snippet:

	public static void main(String[] args) {

		var config = ConfigUtils.loadConfig("examples/scenarios/pt-simple/config.xml");
		var scenario = ScenarioUtils.loadScenario(config);

		System.out.println(scenario.toString());
	}

And everything works fine. Could you please provide the entire stack trace?

A note on how to file issues on Github.