Given that we are in the land of Scheme, why not use SXML? And since we're only converting from SXML to XML, and not the other way around, it was relatively straightforward to copy about ~150 lines of code from Guile 2.x's sxml simple module for the purpose. (Here's the full sxml simple source code.)
There's further to go in this direction, but I didn't want the changes to get any larger.
One small drawback is that by default the sxml->xml function doesn't add line breaks, so the output is not as well formatted for reading, but there are ways to get that back if we want it.
A big benefit is that this approach has been discussed (and used during the Summer of Code project) for adding MusicXML export to LilyPond. So it aligns with that goal. If and when LilyPond moves to a more recent version of Guile, we can easily switch to using the Guile SXML module(s) directly.
Given that we are in the land of Scheme, why not use SXML? And since we're only converting from SXML to XML, and not the other way around, it was relatively straightforward to copy about ~150 lines of code from Guile 2.x's sxml simple module for the purpose. (Here's the full sxml simple source code.)
There's further to go in this direction, but I didn't want the changes to get any larger.
One small drawback is that by default the
sxml->xml
function doesn't add line breaks, so the output is not as well formatted for reading, but there are ways to get that back if we want it.A big benefit is that this approach has been discussed (and used during the Summer of Code project) for adding MusicXML export to LilyPond. So it aligns with that goal. If and when LilyPond moves to a more recent version of Guile, we can easily switch to using the Guile SXML module(s) directly.