Search in sources :

Example 1 with XmlDataException

use of com.xenoage.utils.xml.XmlDataException in project Zong by Xenoage.

the class MusicXmlScoreFileInput method read.

/**
 * Creates a {@link Score} instance from the document
 * behind the given {@link InputStream}.
 * @param inputStream  the input stream with the MusicXML document
 * @param filePath     file path if known, null otherwise
 */
@Override
public Score read(InputStream stream, @MaybeNull String filePath) throws InvalidFormatException, IOException {
    // parse MusicXML file
    MxlScorePartwise score;
    try {
        XmlReader xmlReader = platformUtils().createXmlReader(stream);
        MusicXMLDocument doc = MusicXMLDocument.read(xmlReader);
        score = doc.getScore();
    } catch (XmlDataException ex) {
        // no valid MusicXML
        throw new InvalidFormatException(ex);
    } catch (Exception ex) {
        throw new IOException(ex);
    }
    return read(score, Level.LogErrors);
}
Also used : MxlScorePartwise(com.xenoage.zong.musicxml.types.MxlScorePartwise) XmlReader(com.xenoage.utils.xml.XmlReader) MusicXMLDocument(com.xenoage.zong.musicxml.MusicXMLDocument) XmlDataException(com.xenoage.utils.xml.XmlDataException) IOException(java.io.IOException) InvalidFormatException(com.xenoage.utils.exceptions.InvalidFormatException) IOException(java.io.IOException) XmlDataException(com.xenoage.utils.xml.XmlDataException) InvalidFormatException(com.xenoage.utils.exceptions.InvalidFormatException)

Aggregations

InvalidFormatException (com.xenoage.utils.exceptions.InvalidFormatException)1 XmlDataException (com.xenoage.utils.xml.XmlDataException)1 XmlReader (com.xenoage.utils.xml.XmlReader)1 MusicXMLDocument (com.xenoage.zong.musicxml.MusicXMLDocument)1 MxlScorePartwise (com.xenoage.zong.musicxml.types.MxlScorePartwise)1 IOException (java.io.IOException)1