The attached example-musicxml-display-part-bug.xml shows a minimal
example to trigger the bug. It gives this output:

musicxml2ly: Reading MusicXML from example-musicxml-display-part-bug.xml ...
musicxml2ly: Converting to LilyPond expressions...
Traceback (most recent call last):
  File "/usr/bin/musicxml2ly", line 2986, in <module>
    main()
  File "/usr/bin/musicxml2ly", line 2981, in main
    voices = convert (filename, options)
  File "/usr/bin/musicxml2ly", line 2892, in convert
    score = extract_score_structure (mxl_pl, staff_info)
  File "/usr/bin/musicxml2ly", line 430, in extract_score_structure
    staff = read_score_part (el)
  File "/usr/bin/musicxml2ly", line 383, in read_score_part
    staff.instrument_name = extract_display_text (partname)
  File "/usr/bin/musicxml2ly", line 907, in extract_display_text
    child = el.get_maybe_exist_named_child ("display-text")
  File "/usr/share/lilypond/2.18.2/python/musicxml.py", line 114, in
get_maybe_exist_named_child
    return self.get_maybe_exist_typed_child (get_class (name))
  File "/usr/share/lilypond/2.18.2/python/musicxml.py", line 123, in
get_maybe_exist_typed_child
    raise "More than 1 child", klass
TypeError: exceptions must be old-style classes or derived from
BaseException, not str

The original case where I ran into this is
http://www1.cpdl.org/wiki/images/5/54/Ws-mont-bvf.mxl, which says

   <software>Sibelius 7.5.1</software>
   <software>Direct export, not from Dolet</software>
   <encoding-description>Sibelius / MusicXML 3.0</encoding-description>

I propose the attached musicxml2ly-multi-display-text.patch as a fix.
--- musicxml2ly	2020-03-05 22:30:57.558283750 -0500
+++ musicxml2ly.orig	2020-03-05 22:31:55.449670893 -0500
@@ -904,9 +904,9 @@
     return elts
 
 def extract_display_text (el):
-    children = el.get_typed_children (musicxml.get_class ("display-text"))
-    if children:
-        return " ".join([child.get_text () for child in children])
+    child = el.get_maybe_exist_named_child ("display-text")
+    if child:
+        return child.get_text ()
     else:
         return False
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC
    "-//Recordare//DTD MusicXML 3.1 Partwise//EN"
    "http://www.musicxml.org/dtds/partwise.dtd";>
<score-partwise version="3.1">
  <part-list>
    <score-part id="P1">
      <part-name>Music</part-name>
      <part-name-display>
        <display-text>Player</display-text>
        <display-text>One</display-text>
      </part-name-display>
    </score-part>
  </part-list>
  <part id="P1">
    <measure number="1">
      <attributes>
        <divisions>1</divisions>
        <key>
          <fifths>0</fifths>
        </key>
        <time>
          <beats>4</beats>
          <beat-type>4</beat-type>
        </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
        </clef>
      </attributes>
      <note>
        <pitch>
          <step>C</step>
          <octave>4</octave>
        </pitch>
        <duration>4</duration>
        <type>whole</type>
      </note>
    </measure>
  </part>
</score-partwise>
_______________________________________________
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to