]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: If work-title is empty (but exists), use movement-title instead
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 4 Apr 2009 13:18:38 +0000 (15:18 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 4 Apr 2009 13:18:38 +0000 (15:18 +0200)
input/regression/musicxml/51d-EmptyTitle.xml [new file with mode: 0644]
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/51d-EmptyTitle.xml b/input/regression/musicxml/51d-EmptyTitle.xml
new file mode 100644 (file)
index 0000000..49a089b
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN"
+                                "http://www.musicxml.org/dtds/partwise.dtd">
+<score-partwise version="2.0">
+  <work>
+    <work-number></work-number>
+    <work-title></work-title>
+  </work>
+  <movement-number></movement-number>
+  <movement-title>Empty work-title, non-empty movement-title</movement-title>
+  <identification>
+    <miscellaneous>
+      <miscellaneous-field name="description">A piece with an empty (but
+            existing) work-title, but a non-empty movement-title. In this case
+            the movement-title should be chosen, even though the work-title
+            exists.</miscellaneous-field>
+    </miscellaneous>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name print-object="no">MusicXML Part</part-name>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <note>
+        <rest/>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+  </part>
+  <!--=========================================================-->
+</score-partwise>
index 5a8896c1b0b297b0594803cbe2d7aae83c099426..33c0aca03925e8830ff73a6178b18c259aaabae1 100644 (file)
@@ -273,15 +273,15 @@ def extract_score_information (tree):
         if value:
             header.set_field (field, musicxml.escape_ly_output_string (value))
 
+    movement_title = tree.get_maybe_exist_named_child ('movement-title')
+    if movement_title:
+        set_if_exists ('title', movement_title.get_text ())
     work = tree.get_maybe_exist_named_child ('work')
     if work:
+        # Overwrite the title from movement-title with work->title
         set_if_exists ('title', work.get_work_title ())
         set_if_exists ('worknumber', work.get_work_number ())
         set_if_exists ('opus', work.get_opus ())
-    else:
-        movement_title = tree.get_maybe_exist_named_child ('movement-title')
-        if movement_title:
-            set_if_exists ('title', movement_title.get_text ())
     
     identifications = tree.get_named_children ('identification')
     for ids in identifications: