Feature-request: XML-includes

34 views
Skip to first unread message

Danyel André

unread,
Nov 3, 2017, 12:08:04 PM11/3/17
to MIDI2LR
For easier profile management it would be great if XML-includes are supported.

With that feature it's possible to gerate e. g. a basic profile with settings what have to be the same in other profiles.

I have tried several methods but the XML-parser from midi2lr doesn't seem to support includes.

Or is there already a way for nesting XML files?

Lev Flitman

unread,
Nov 4, 2017, 10:59:16 AM11/4/17
to MIDI2LR
I have came up with a workaround solution recently. It's a kludge, but it works. Here is what you have to do:
  • create a profile containing all mappings for your "basic profile", i.e. the ones that should be the same in all profiles. I call this one the CORE profile.
  • create a new empty profile and map all the functions, e.g. for develop module, that have to be in this profile, except for those already in CORE profile. Let's call this one CORE_DEV.
  • open your favorite text editor and manually paste the lines from both CORE_DEV and CORE to make a new final profile for, in this case, develop module. Save it as a new file, let's call it simply DEV.
  • optionally, you can add a comment tag between the two segments of profile if you want, which will make further editing much easier, like this:
    <!-- your XML comment text goes here -->
Keep in mind though, that for this approach to work well, you can't change and then save the final profiles via the plugin any more, otherwise the plugin will remove all the comment lines and will also shuffle the mapping lines inside the xml file. From now on, in order to make changes to the final profile, you will have to edit the CORE profiles only (the usual way, through the plugin), and then merge them into the final profiles by hand.

The process is highly manual and requires you to also keep an eye on your mappings so you don't have several functions assigned to the single controller CC/button. I found that it's easier to track this using Excel or other spreadsheet software as it allows you to sort the data, check for duplicates and then copy the data back to the xml file easily. Thankfully, the xml/plugin treats tab and space equally.

You can use additional comment fields in the spreadsheet (that you won't copy into the profile itself) to make an ad-hoc profile builder. I suppose it's quite possible to make a spreadsheet-based solution with interactive graphical layout on one page, all the API calls and MIDI2LR profile variables on another, and with the final xml-ready output on the third page.

Danyel André

unread,
Nov 4, 2017, 11:36:32 AM11/4/17
to MIDI2LR
Hi Lev,

thank you for the detailed workaround. This is the way I already figured out. But it's a pain in the a** if you do a little change in the core settings.

As far as I know inclusion of TXT and XML-files is defined in XML standards. So it would be lovely and helpful if the midi2lr parser will support that in future versions.

Lev Flitman

unread,
Nov 4, 2017, 12:34:29 PM11/4/17
to MIDI2LR


On Saturday, 4 November 2017 18:36:32 UTC+3, Danyel André wrote:
Hi Lev,

thank you for the detailed workaround. This is the way I already figured out. But it's a pain in the a** if you do a little change in the core settings.

Well, it's much less of a pain compared to editing the same mapping in each profile separately. At least here you just edit it once, and then copy the changes to all the files. It's a little bit more efficient this way.

 
As far as I know inclusion of TXT and XML-files is defined in XML standards. So it would be lovely and helpful if the midi2lr parser will support that in future versions.

The only way to implement this that I can think of from the top of my head is by means of switches, or locks, so you can lock a particular mapping and it will remain in place even if you create a new profile or clear the current one loaded.

Jay Kreibich

unread,
Nov 4, 2017, 3:20:12 PM11/4/17
to MIDI2LR, Danyel André

If you have any development skills, there are a ton of text-processing tools out there. I’d be surprised if you can’t find an XML “compiler” that can resolve the include statements and generate flat XML files.

Heck, you should be able to do something like that with something as simple at the C pre-processor and #include statements.  Have your set of hand-edited files that you use to “compile" the actual preference files.  That eliminates the tedious manual process.

In none of these cases would you be able to save new profiles from within the application.  I suspect that’s part of the reason includes are not processed… that type of thing is most often used when the files are external edited/created, and simply consumed by a different application.  In this case midi2lr needs to be read and generate the files, and it is unrealistic for it to keep track of the read structure so it knows the correct file to edit.  It’s just going to blast out a flat config file on every save.

 -j



--
You received this message because you are subscribed to the Google Groups "MIDI2LR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to midi2lr+u...@googlegroups.com.
To post to this group, send email to mid...@googlegroups.com.
Visit this group at https://groups.google.com/group/midi2lr.
To view this discussion on the web visit https://groups.google.com/d/msgid/midi2lr/2c3d812b-1785-4c6f-97e9-7875f32ab3f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lev Flitman

unread,
Nov 5, 2017, 6:06:29 AM11/5/17
to MIDI2LR
Unfortunately, I have no programming skills, so a spreadsheet-based solution is basically the best I can do at this point.
Reply all
Reply to author
Forward
0 new messages