Modern xml library for lua with attributes and xpath support

Hi,

I am looking for a modern syntax xml library for lua, which actually supports attributes. Does not require a dom parser or similar. So far only found this one:

But I need to do this in both directions, luatable2xml and xml2luatable… Any hint for me?

Also is there a way to use VSCode as IDE for Renoise development? Having autocomplete, autoformat, known Renoise base libs, etc, just the normal stuff? External source updating still does not seem to be supported…

Good point, maybe having xmlpath would be pretty handy.

Maybe this? GitHub - duhoobo/lua-xpath: A Lua XPath library based on libxml2.
But it reuqires libxml2, and it seems to me that I cannot use such modules in Renoise lua, seem to require another lua build… No luarocks support either.

So I am looking for a xml lib, usable in Renoise, which supports xpath, and also creating xml with attributes. Nice would be schema file validation support, too. It is funny how this seems to be a perfect job for javascript…

Any idea for me?

Would probably just craft a regex to get it done; hth.

1 Like

Agreed, more or less, on using a regex. Depending on your use case it may be simplest to iterate over a table and build up a string of XML.

The reverse may be trickier, but, again, if you control the XML (or know for sure what to expect) then hand-parsing might not be too bad.

But what’s the actual use case that you need this XML/table conversion? Maybe there’s some other way to do what you want.

FWIW I use vim for Renoise tool development, and have some Ruby scripts to package up the source files and update the tools in my Renoise folder.

regex is way too cumbersome. I need to build a very complex xml, based on song data, and also parse such a xml structure to build a renoise song. Using regex would turn this into an insane and also badly debuggable mess.

xpath might be a good idea, or maybe a dom parser would be actually a good idea then. But lua seems to be quite retarded here, or requires addional pre-compiled extensions here. Which are not part of Renoise’s lua component.

Javascript ES6 seems to bring all those requirements on the table out of the box already, sadly there is no javascript scripting in Renoise.

So it currently seems to be an immense amount of work to build a dawproject export/import, due limitations. But maybe I am wrong and you have some ideas here?

Can I set attributes with the Renoise document api, and traverse/search thru a xml?

Your original suggestion is bidirectional - XML to table and table to XML. This looks good enough for the task?

The “xpath support” I don’t quite understand. Isn’t it enough to just traverse/filter anything you need with custom lua after the import to table is done?

Maybe you are right about that. So I just need renoise document api capable of attributes? Any third party suggestion then?

Being able to use XPath or Dom queries might be more comfortable and future save though…

I would not care about the document API or xpath. If it’s simple enough to do with normal Lua, it seems rational to minimize unnecessary abstractions and dependencies.

If xml2lua(table) can be made up and running, I would guess the main hurdle will be fxb (vst data) and how to interpret audio tracks on import. Some things I guess will have to be stripped (warping data maybe?), but could possibly be stored/reused via tool_data to break as little as possible when moving between DAWs.

A nice nested class structure with separate import/export/render functions for the various XML node-types would make the code easy to maintain and understand.

Hello,

this lua xml lib looks very good, but it is installed via luarocks and somehow uses libxml2, the system lib: Install | XMLua

Can I use this in Renoise?

EDIT: It seems to support everything, see here: Tutorial | XMLua

  • Both directions
  • Creating single nodes programatically
  • Searching
  • XML and HTML

Also looks very html browser like.

This would be a good foundation, but I have no idea how to use it, if it is installed via luarocks and uses bindings to sqllib2 (which i think is commonly installed under macos and linux?).

Could Renoise support libxml2 and luarocks and luajit? Or is this working already, if I install this via luarocks and then copy from the installation dir?

Every user that uses your tool would then need to install luarocks and the correct binaries for the platform that your tool is running on.

It’s not impossible, but it’s way easier for everyone to use plain lua libraries which you then simply bundle with your tool.

1 Like

Do you know such an xml library? Should have the above features… Can’t find a proper one without bundled with luarocks. The internal document api does not support attributes or searching AFAIK, or does it?