-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XMLLyricLanguage has no attribute {http://www.w3.org/XML/1998/namespace}lang #6
Comments
The parse_musicxml function is not really matured yet. Until now the focus of both libraries musicxml and musicscore was to create MusicXML files rather than importing or analysing them, though that could be a very interesting feature for the future. So in the long run it would be desirable to fix this function to be able to parse also MusicXML files which are created with Sibelius. So if you have a good idea for an easy fix, go for it. Please keep in mind that the tests for this function are also still only a rough draft and are not included yet in the test suite. |
Do you have an idea how we could design tests for parse_musicxml function to cover all these kinds of problems? If you are going to invest some time in enhancing this function it would be nice to think about testing first. But anyway feel free to add issues and describe your ideas. It doesn’t do any harm at all!
… Am 04.02.2024 um 16:51 schrieb Mike Echo ***@***.***>:
I found another issue where <miscellaneous-field> elements (as part of https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/miscellaneous/) can't be parsed correctly. Should I create a new issue for it to describe in detail? I've been thinking of some solution options for it which I can describe in there.
—
Reply to this email directly, view it on GitHub <#6 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFPSJTQQDZLGWUKQAJ42DO3YR6VAHAVCNFSM6AAAAABCSB75U2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVHAYDCOJUGY>.
You are receiving this because you commented.
|
I'll be responding here soon, sorry for the delay. I'll create an issue for the other bug I found :) |
Definitely, any issue found must have at least one test case (or more) to back it up. Currently I've created a simple test that invokes the
At this stage I'm considering which approach to fix it is most maintainable in the long run, since namespaces are an integral part of XML, and in musicXML there are multiple instances where a namespace is used in an element attribute. |
Hi @alexgorji, I've isolated the root cause for why
It is not a fault of the function itself, but of how the I'd like to ask why you hardcoded |
Hi @MikeEcho, |
@alexgorji it'll be my pleasure! Before I do that, I'd like to brainstorm options for a fix, because there are different ways we could go about this. As the main maintainer of this library, you'd probably be in the best position to know which option is best. What we know:
First off, I assume we will want the ability to export namespaced attributes (e.g. export Python -> musicxml with a lyric-language element specifying xml:lang="some language code"). Otherwise we'd have to build in some way for the "namespace matcher" at export time to figure out erased namespace associations and attach them as expected by the musicxml schema within the elements to be exported, which seems a bit messy. Therefore, going with the first assumption, we will need to maintain this namespace info somewhere so it can be accessed for export. The question then becomes: how should namespaces be represented within the library w.r.t element attributes which rely on them according to the musicxml schema? For a class like Alternatively, we take a more "sophisticated" approach by introducing some sort of attribute-namespace mapping within a relevant element class like If you have any other ideas, please let me know, and I hope that wasn't too long! Namespace parsing will be an important milestone in the development of this library I think! |
I see. It could indeed get a little bit complicated. I admit that I did have neglected these namespace exceptions at the first place but I understand the need to change it now. I created an extra branch for this issue to be able to experiment around without damaging the master branch. I would suggest that you add one or more tests to: musicxml/tests/test_xsd/test_xsd_attribute.py to determine exactly which changes we are looking for. Then we can decide how deep we need to go into the subject. I would recommend to stick to a tdd workflow: 1- Write a test that fails. 2- Make minimal changes to the code for the test to pass. 3- Refactor the changes if necessary to have a clean code. |
I wanted to point out a curious issue that arises immediately when I try to parse an XML exported directly from Sibelius Ultimate version 2022.12. I've read in your documentation that this library has been built with Finale in mind rather than other sheet music software, but I figure I'd ask just in case.
Calling
score = parse_musicxml(Path(__file__).parent / 'test_language.xml')
in a unit test I was able to reproduce this error for where the XML file itself contains the XML block beforepart-list
:causes the exception (in the issue title) to be thrown. Full error message:
In debug mode I found that the
{http://www.w3.org/XML/1998/namespace}lang
key was already set afterxml
library callsET.parse()
:Which seems to me to be not an issue with this
musicxml
library, but withxml
?Because of this initial finding, I'm inclined to close this issue and code a workaround where my own
xml
code removes theXMLLyricLanguage
element first before parsing the rest of the XML. Just wanted to get your thoughts before I do that!The text was updated successfully, but these errors were encountered: