Skip to content
MusicXML parser to RDF based in the MusicOWL Ontology
Branch: master
Clone or download
Latest commit 6039c6b Sep 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
musicowl Refactoring on XML/JSON metadata format. Sep 16, 2019
.travis.yml Update .travis.yml Jul 9, 2019
LICENSE Update LICENSE Jul 17, 2019 Update Sep 16, 2019

Build Status Maven Central License: MIT Contribute: Gitpod

Music Score to RDF Converter

This converter parses MusicXML 3.0 files and converts them to RDF, based on the MusicOWL Ontology [ˈmjuːzɪkəl]. It fully supports the following concepts:

  • Articulations
  • Clefs
  • Durations
  • Dynamics
  • Measures (Bars)
  • Note Sets
  • Notes
  • Staves
  • Tonalities
  • Voices


setInputFile  MusicXML 3.0 file to be converted. Supported are .xml and .mxl files.

setOutputFile  Path and name for RDF output file.

setThumbnail  Thumbnail for the converted music score (optional).

setScoreIdentifier  URI for the converted score (optional) .

setScoreTitle  Music score title.

issued  Date issued. Formats accepted: yyyy, yyyyMM, yyyyMMdd (optional).

setCollection  Collections can be used for classifying music scores into certaing groups, e.g. "18th Century Composers", "Advanced Music Scores", etc.

isVerbose  Setting it to true logs in the console the converter progress.

setOutputFormat  Sets the RDF notation for the output file. Accepted notations are: TURLTE, NTRIPLES, JSON-LD, RDF/XML, RDF/JSON.

addPerson  This method can be used to add persons related to the music score. It consists of an URI, a name and a role, which can have one of the following attributes:


addResource  Links existing resources to the converted music score, such as pdf or mp3 files. This method relies on three parameters:

  • Link: Link to the resource
  • Description: Text describing the resource
  • Type: MIME Type

Music2RDF at Maven Central

To add the Music Score to RDF Converter to your project just add the following dependency in your pom.xml file:


Using the Java API

The above mentioned parameters can be used as follows:

package de.wwu.music2rdf.example;



import de.wwu.music2rdf.converter.MusicXML2RDF;
import de.wwu.music2rdf.core.Collection;
import de.wwu.music2rdf.core.Person;
import de.wwu.music2rdf.core.Role;
import de.wwu.music2rdf.core.ScoreResource;

public class Example {

  public static void main(String[] args) {
    MusicXML2RDF music2rdf = new MusicXML2RDF();
    music2rdf.setInputFile(new File("musicxml/ulb-muenster/elgar_cello_concerto_op.85.xml"));
    music2rdf.addCollection(new Collection("","Great Composers"));
    music2rdf.addCollection(new Collection("","Digitale Sammlung der Universität und Landesbibliothek Münster"));
    music2rdf.addPerson(new Person("","Sir Edward William Elgar",Role.COMPOSER));
    music2rdf.addPerson(new Person("","Jim Jones",Role.ENCODER));
    music2rdf.addResource(new ScoreResource("", "Print",MediaType.PDF.toString()));
    music2rdf.addResource(new ScoreResource("", "Wikipedia Article",MediaType.HTML_UTF_8.toString()));
    music2rdf.setScoreTitle("Cellokonzert e-Moll op. 85");
    music2rdf.setDateIssued("1919"); //Formats accepted: yyyy, yyyyMM, yyyyMMdd.    	

Using the converter in the console

If you don't feel like building the Musci2RDF converter from source, visit the releases area to get a prebuilt jar. You can use this jar with following parameters:

metadata  In order to keep the full metadata support via console, you have to pass the metadata in separated file. This metadata file can be encoded in XML ...

<?xml version="1.0" encoding="UTF-8"?>
	<scoreTitle>Cellokonzert e-Moll op. 85</scoreTitle>
			<collectionLabel>Great Composers</collectionLabel>
			<personName>Sir Edward William Elgar</personName>
			<personName>Jim Jones</personName>
			<resourceLabel>Wikipedia Article</resourceLabel>

.. or in case you fancy JSON:

   "scoreIdentifier": "",
   "scoreTitle": "Cellokonzert e-Moll op. 85",
   "thumbnail": "",
   "issued": "1919",
   "collections": [       
         "collectionLabel": "Great Composers",
         "collectionIdentifier": ""
   "persons": [
         "personIdentifier": "",
         "personName": "Sir Edward William Elgar",
         "personRole": "Composer"
         "personIdentifier": "",
         "personName": "Jim Jones",
         "personRole": "Encoder"
   "resources": [
         "resourceURL": "",
         "resourceLabel": "Print",
         "resourceType": "application/pdf"
         "resourceURL": "",
         "resourceLabel": "Wikipedia Article",
         "resourceType": "text/html"

Further parameters are:

file   Music score file.

output  Name for the output file.

outputFormat  RDF notation for the output file

Example (using the above described metadata file):

$ java -jar music2rdf-[VERSION].jar file=musicxml/metadata-file/elgar_cello_concerto_op.85.xml

File  	        : musicxml/elgar_cello_concerto_op.85.xml
Score URI       :
Title           : Cellokonzert e-Moll op. 85
Date Issued     : 1919
Thumbnail       :
Person URI      :
Person Name     : Sir Edward William Elgar
Person Role     : Composer
Person URI      :
Person Name     : Jim Jones
Person Role     : Encoder
Resource URI    :
Resource Desc.  : Print
Resource Type   : application/pdf
Resource URI    :
Resource Desc.  : Wikipedia Article
Resource Type   : text/html
Collection URI  :
Collection Name : Great Composers
Output File     : rdf/elgar_cello_concerto_op.85
OutputFormat    : turtle

[2019-08-11 19:33:14,788] INFO  [Converter] - Processing elgar_cello_concerto_op.85.xml ...
[2019-08-11 19:33:15,011] INFO  [Converter] - Loading XML file: 222 ms
[2019-08-11 19:33:15,341] WARN  [Converter] - The title "Cellokonzert e-Moll op. 85" was provided and will therefore overwrite the title provided in the MusicXML document.
[2019-08-11 19:33:15,341] INFO  [Converter] - Creating MusicScore object: 329 ms
[2019-08-11 19:33:16,224] INFO  [Converter] - Score serialization: 883 ms
You can’t perform that action at this time.