progval / rust-xml-schema

[WIP] (Self-generating) XML parser generator based on XML schemas.
GNU Affero General Public License v3.0
28 stars 3 forks source link

Fails to generate MusicXML schema #6

Open azmeuk opened 4 years ago

azmeuk commented 4 years ago

MusicXML is a W3C standard for music notation.

I tried to play with rust-xml-schema and the MusicXML schema, and here is what happened:

$ wget https://raw.githubusercontent.com/w3c/musicxml/gh-pages/schema/musicxml.xsd -O xml-schema/musicxml.xsd
$ env RUST_BACKTRACE=full cargo run --package xml-schema --bin gen xml-schema/musicxml.xsd
thread 'main' panicked at 'Expected one of ["#all"], got "extension substitution"', xml-schema/src/primitives.rs:131:9
stack backtrace:
   0:     0x556d16e20524 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7b11b2a23cd910b3
   1:     0x556d16e363dc - core::fmt::write::hca7efce6c0791439
   2:     0x556d16e1ec37 - std::io::Write::write_fmt::he56b7f6fb86cf3b5
   3:     0x556d16e224de - std::panicking::default_hook::{{closure}}::hf51e7f0a7424f5cd
   4:     0x556d16e221d1 - std::panicking::default_hook::he8ba9c8182908cf7
   5:     0x556d16e22b0b - std::panicking::rust_panic_with_hook::hf9a08396e191b616
   6:     0x556d16e226be - rust_begin_unwind
   7:     0x556d16e22600 - std::panicking::begin_panic_fmt::hfd104289df6728bf
   8:     0x556d16d19c74 - <xml_schema::primitives::Token as xml_schema::support::ParseXmlStr>::parse_self_xml_str::h6908c3ad8b9d1f13
                               at xml-schema/src/primitives.rs:131
   9:     0x556d16d18140 - xml_schema::support::ParseXmlStr::parse_xml_str::hfdc9e574e37ca3fe
                               at xml-schema/src/support.rs:153
  10:     0x556d16d2ff4a - <xml_schema::parser::restrictions::All as xml_schema::support::ParseXmlStr>::parse_self_xml_str::h674cfbdd4c9cc9f7
                               at xml-schema/src/macros.rs:504
  11:     0x556d16d20b70 - xml_schema::support::ParseXmlStr::parse_xml_str::hd8070b50b6a4b405
                               at xml-schema/src/support.rs:153
  12:     0x556d16cce4d7 - <xml_schema::parser::unions::UnionTokenDerivationControlList as xml_schema::support::ParseXmlStr>::parse_self_xml_str::h3e6739fcab311459
                               at xml-schema/src/macros.rs:443
  13:     0x556d16ccd180 - xml_schema::support::ParseXmlStr::parse_xml_str::h80f7a12a3c644a00
                               at xml-schema/src/support.rs:153
  14:     0x556d16c1254e - <xml_schema::parser::xs::Element as xml_schema::support::ParseXml>::parse_self_xml::hff05a00496329bca
                               at xml-schema/src/macros.rs:276
  15:     0x556d16be39e0 - xml_schema::support::ParseXml::parse_xml::ha293b3e56aec22e8
                               at xml-schema/src/support.rs:136
  16:     0x556d16c7dfaf - <xml_schema::parser::xs::SchemaTop as xml_schema::support::ParseXml>::parse_self_xml::hc1daa1ae62f9dd63
                               at xml-schema/src/macros.rs:42
  17:     0x556d16be3de9 - xml_schema::support::ParseXml::parse_xml::hca4f4a3d53f262fe
                               at xml-schema/src/support.rs:136
  18:     0x556d16bc89f1 - <xml_schema::parser::sequences::SequenceSchemaTopAnnotation as xml_schema::support::ParseXml>::parse_self_xml::hb2d5f97c3eb45e30
                               at xml-schema/src/macros.rs:202
  19:     0x556d16bc7e5d - xml_schema::support::ParseXml::parse_xml::h2aef1b4d10491659
                               at xml-schema/src/support.rs:136
  20:     0x556d16c60e19 - <xml_schema::parser::xs::Schema as xml_schema::support::ParseXml>::parse_self_xml::h43b3b3e5a13031e7
                               at xml-schema/src/macros.rs:310
  21:     0x556d16be3400 - xml_schema::support::ParseXml::parse_xml::h565e80bf15f527ee
                               at xml-schema/src/support.rs:136
  22:     0x556d16b4db2e - xml_schema::parse_xsd_with_visitor::h517b71e70c030c7b
                               at xml-schema/src/lib.rs:39
  23:     0x556d16b1810f - gen::main::hc0991bd4eaf1bba4
                               at xml-schema/src/bin/gen.rs:44
  24:     0x556d16b14ce0 - std::rt::lang_start::{{closure}}::h0cb263f2fed267a6
                               at /build/rust/src/rustc-1.41.0-src/src/libstd/rt.rs:67
  25:     0x556d16e225a3 - std::panicking::try::do_call::hd0ef6b95899a3d3b
  26:     0x556d16e2438a - __rust_maybe_catch_panic
  27:     0x556d16e22fa0 - std::rt::lang_start_internal::hd59341531b4fe1e8
  28:     0x556d16b14cb9 - std::rt::lang_start::hbeacabebb6a1ef50
                               at /build/rust/src/rustc-1.41.0-src/src/libstd/rt.rs:67
  29:     0x556d16b18a0a - main
  30:     0x7fee0e2bf153 - __libc_start_main
  31:     0x556d16b0f0be - _start
  32:                0x0 - <unknown>

I opened this ticket for the record :) as rust-xml-schema is still in a very early stage.

webern commented 3 years ago

@azmeuk did you find a generator that could produce the MusicXML schema for rust?

azmeuk commented 3 years ago

Nope. But I was not actively searching neither.

Matthias-Fauconneau commented 3 years ago

Just in case, you don't require the XML schema way yet, you might be interested in my partial translation in serde+ notation https://github.com/Matthias-Fauconneau/musicxml/blob/master/src/music_xml.rs This use my serde-roxmltree interface which has some extensions to help translate XML schemas in serde notations.