X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=scm%2Fto-xml.scm;h=82c563da6b33d72dffebcd559b604d13bbb05d12;hb=a73acd2168158da65f4f2340b5c9cdeb1fd60fd2;hp=f991d5eed2a7dd4fa4477f0df8552608d2099d65;hpb=34881554afeaf03a55a3a983caf9cfeaaf3ea060;p=lilypond.git diff --git a/scm/to-xml.scm b/scm/to-xml.scm index f991d5eed2..82c563da6b 100644 --- a/scm/to-xml.scm +++ b/scm/to-xml.scm @@ -2,11 +2,14 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2003--2004 Han-Wen Nienhuys +;;;; (c) 2003--2009 Han-Wen Nienhuys ;;;; Jan Nieuwenhuizen +(define-module (scm to-xml)) + (use-modules (ice-9 regex) (srfi srfi-1) + (lily) (oop goops)) " @@ -47,20 +50,19 @@ is then separated. (pitch . pitch) (duration . duration) (octave . octave) - (step . step) - )) + (step . step))) (define (musicxml-node->string node) (let ((xml-name (assoc-get (node-name node) node-names #f))) - (string-append - (if xml-name (open-tag xml-name '() '()) "") - (if (equal? (node-value node) "") - (string-append - (if xml-name "\n" "") - (apply string-append (map musicxml-node->string (node-children node)))) - (node-value node)) - (if xml-name (close-tag xml-name) "") - (if xml-name "\n" "")))) + (string-append + (if xml-name (open-tag xml-name '() '()) "") + (if (equal? (node-value node) "") + (string-append + (if xml-name "\n" "") + (apply string-append (map musicxml-node->string (node-children node)))) + (node-value node)) + (if xml-name (close-tag xml-name) "") + (if xml-name "\n" "")))) (define (xml-node->string node) (string-append @@ -87,26 +89,13 @@ is then separated. (numer . ,(car (ly:duration-factor d))) (denom . ,(cdr (ly:duration-factor d)))))) -(define (musicxml-pitch->xml-node p) - (make - #:name 'pitch - #:children - (list - (make - #:name 'step - #:value (list-ref '("C" "D" "E" "F" "G" "A" "B") - (ly:pitch-notename p))) - (make - #:name 'octave - #:value (number->string (ly:pitch-octave p)))))) - (define (pitch->xml-node p) (make #:name 'pitch #:attributes `((octave . ,(ly:pitch-octave p)) (notename . ,(ly:pitch-notename p)) (alteration . ,(ly:pitch-alteration p))))) - + (define (music->xml-node music) (let* ((name (ly:music-property music 'name)) (e (ly:music-property music 'element)) @@ -136,8 +125,8 @@ is then separated. ]> ")) - - + + ;; as computed from input/trip.ly, by ;; http://www.pault.com/pault/dtdgenerator/ @@ -188,7 +177,7 @@ is then separated. (define (assert x) (if x #t - (error "assertion failed"))) + (ly:error (_ "assertion failed: ~S") x))) (define (re-sub re to string) (regexp-substitute/global #f re string 'pre to 'post)) @@ -211,20 +200,16 @@ is then separated. (not (memq (car x) exceptions))) (define (dump-attr sym-val) - (let* - ( - (sym (car sym-val)) - (val (cdr sym-val)) - ) + (let* ((sym (car sym-val)) + (val (cdr sym-val))) - (string-append - "\n " - (symbol->string sym) - "=\"" - (let ((s (call-with-output-string (lambda (port) (display val port))))) - (re-sub-alist s xml-entities-alist)) - "\"" - ))) + (string-append + "\n " + (symbol->string sym) + "=\"" + (let ((s (call-with-output-string (lambda (port) (display val port))))) + (re-sub-alist s xml-entities-alist)) + "\""))) (string-append "<" (symbol->string tag) @@ -252,7 +237,6 @@ is then separated. ;; ;; (display (dtd-header) port) - (define pitch->xml-node musicxml-pitch->xml-node) (define duration->xml-node musicxml-duration->xml-node) (display (open-tag 'music '((type . score)) '()) port)