Validating Midnams with something other than xmllint

xmllint will not validate when the dtd is from an https source.

Is there a newer way to validate xml ?

Per the author’s comments in the Gitlab issue, the preferred mode is to install the external DTDs into your local XML catalog, which lives in /etc/xml on a Linux machine. The trick here is to thing of the string http://www.midi.org/dtds/MIDINameDocument10.dtd as a URI (a globally-unique identifier) for the DTD, rather than its URL (the place where you happen to be able to fetch the DTD as a file).

I just tried the following:

$ sudo cp /etc/xml/catalog{,-ASIDE}  # save backup copy
$ sudo mkdir /etc/xml/midi  #  put MIDI-related catalog entries here
$ sudo wget -nv -O /etc/xml/midi/MIDINameDocument10.dtd http://www.midi.org/dtds/MIDINameDocument10.dtd
2024-01-10 02:22:32 URL:https://midi.org/dtds/MIDINameDocument10.dtd [4498/4498] -> "/etc/xml/midi/MIDINameDocument10.dtd" [1]
$ sudo xmlcatalog --noout --add system http://www.midi.org/dtds/MIDINameDocument10.dtd midi/MIDINameDocument10.dtd /etc/xml/catalog
$ grep MIDI /etc/xml/catalog
  <system systemId="http://www.midi.org/dtds/MIDINameDocument10.dtd" uri="midi/MIDINameDocument10.dtd"/>

Next, I tried to validate one of the midnam files shipped by Ardour:

$ xmllint --noout --valid /opt/Ardour-8.2.0/share/patchfiles/MIDI.midnam && echo YES || echo NO
error : Unknown IO error
file:///etc/xml/midi/MIDINameDocument10.dtd:154: warning: failed to load external entity "http://www.midi.org/dtds/MIDIEvents10.dtd"
...

So, we need to download and install another DTD, this one for MIDI events:

$ sudo wget -nv -O /etc/xml/midi/MIDIEvents10.dtd https://midi.org/dtds/MIDIEvents10.dtd
2024-01-10 02:25:51 URL:https://midi.org/dtds/MIDIEvents10.dtd [6363/6363] -> "/etc/xml/midi/MIDIEvents10.dtd" [1]
$ sudo xmlcatalog --noout --add system http://www.midi.org/dtds/MIDIEvents10.dtd midi/MIDIEvents10.dtd /etc/xml/catalog
$ grep MIDI /etc/xml/catalog
  <system systemId="http://www.midi.org/dtds/MIDINameDocument10.dtd" uri="midi/MIDINameDocument10.dtd"/>
  <system systemId="http://www.midi.org/dtds/MIDIEvents10.dtd" uri="midi/MIDIEvents10.dtd"/>

And try the validation again:

$ xmllint --noout --valid /opt/Ardour-8.2.0/share/patchfiles/MIDI.midnam && echo YES || echo NO
YES
3 Likes

Nice walkthough. Thanks

The two document type definition files are included with Ardour’s source in share/patchfiles/ (but not installed), so it’s easier to validate if you have the source code around.

Thank you for this! It worked!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.