Search code examples
javajfuguemusicxml

Musixml parsing exception when trying to parse with JFugue, how to fix this?


I'm having a error when trying to parse musicxml files, tried with both JFugue 4.0.3 and 5.0.5.

Invocation (JFugue 4.0.3):

MusicStringRenderer renderer = new MusicStringRenderer();
MusicXmlParser parser = new MusicXmlParser();                   
parser.addParserListener(renderer);     
parser.parse(inputFile);

I have been using the musicxml parsing capability of JFugue before and everything worked then, but now it is giving me this error:

java.io.IOException: Server returned HTTP response code: 403 for URL:   http://www.musicxml.org/dtds/partwise.dtd
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1628)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:646)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1304)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1270)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:263)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1167)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1050)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:964)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at nu.xom.Builder.build(Unknown Source)
at nu.xom.Builder.build(Unknown Source)
at nu.xom.Builder.build(Unknown Source)
at org.jfugue.MusicXmlParser.parse(MusicXmlParser.java:137)

The link partwise.dtd file is still located at the link, but downloading is denied. Is it possible to link to the file locally?


Solution

  • A workaround I used for not getting the dtd files from the musicxml official site was to refer to it locally, this way you don't need a network connection to read musicxml files. Such as this:

    <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN" "../musicxmldtd/partwise.dtd">