[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: converting LilyPond score to XML
From: |
David Kastrup |
Subject: |
Re: converting LilyPond score to XML |
Date: |
Thu, 05 Feb 2015 09:40:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Wilbert Berendsen <address@hidden> writes:
> Friends,
>
> there have been some efforts in the past to convert LilyPond music to
> XML. One of the approaches would be to convert the LilyPond music tree
> to XML and be able to process it with other tools, which could read the
> XML and convert it to MusicXML or other XML music formats.
>
> I have now written a script that can be included in a LilyPond file and
> has functions that can map LilyPond score, music and markup objects
> etc. to XML, which is written to the current output port (standard
> output).
>
> The script is here[1] and there is some documentation included and also
> visible here[2].
>
> [1]
> https://github.com/wbsoft/python-ly/blob/master/ly/xml/xml-export.ily
> [2]
> http://python-ly.readthedocs.org/en/latest/ly.xml.html#the-xml-export-ily-file
Hi Wilbert,
taking a look at it, my "reinvention of the wheel" warning lamp is
flickering. Admittedly, in the current state it seems like less work
than reusing the existing wheel. Which would be according to the
GUILE-2.0 manual:
File: guile-2.0.info, Node: SXML, Next: Texinfo Processing, Prev:
Statprof, Up: Guile Modules
7.22 SXML
=========
SXML is a native representation of XML in terms of standard Scheme data
types: lists, symbols, and strings. For example, the simple XML
fragment:
<parrot type="African Grey"><name>Alfie</name></parrot>
may be represented with the following SXML:
(parrot (@ (type "African Grey)) (name "Alfie"))
SXML is very general, and is capable of representing all of XML.
Formally, this means that SXML is a conforming implementation of the
http://www.w3.org/TR/xml-infoset/ (XML Information Set) standard.
Guile includes several facilities for working with XML and SXML:
parsers, serializers, and transformers.
* Menu:
* SXML Overview:: XML, as it was meant to be
* Reading and Writing XML:: Convenient XML parsing and serializing
* SSAX:: Custom functional-style XML parsers
* Transforming SXML:: Munging SXML with ‘pre-post-order’
* SXML Tree Fold:: Fold-based SXML transformations
* SXPath:: XPath for SXML
* sxml apply-templates:: A more XSLT-like approach to SXML
transformations
* sxml ssax input-parse:: The SSAX tokenizer, optimized for Guile
It turns out that those libraries are also available for GUILE-1.8
(I think you can install them with
sudo apt-get install guile-library
on Ubuntu). So it definitely makes sense using that kind of
representation, and it should provide a good toolbox for eventually
converting to MusicXML as well.
--
David Kastrup