aminya / AcuteML.jl

Acute Markup Language - HTML/XML in Julia
https://aminya.github.io/AcuteML.jl/dev
MIT License
6 stars 4 forks source link

Generate Julia types from XML schema files #154

Open kskyten opened 3 years ago

kskyten commented 3 years ago

It would be extremely useful to generate Julia types from XML schema files automatically. This would make it easy to generate, for example, SVG and MathML. Here is some useful code to handle XSD fschema files in Julia.

aminya commented 3 years ago

You can parse any XML file if you declare its structure using @aml macro.

See MusicXML.jl for an example of a library that uses AcuteML: https://github.com/JuliaMusic/MusicXML.jl

kskyten commented 3 years ago

Yes, but you have to define the structure of the XML in Julia first. What I'm looking for is automatically generating this Julia code to parse and generate XML based on it's schema. In MusicXML's case I would take the XML schema from here: https://www.musicxml.com/for-developers/musicxml-xsd/ and automatically generate the AcuteML code.

MusicXML
MusicXML W3C XML Schema Definition (XSD)
XSD provides a stricter definition of the MusicXML 3.1 format than the MusicXML Document Type Definition (DTD).
aminya commented 3 years ago

@kskyten This seems like a very good idea. However, I am not sure how we should approach this.

It is also related to #93.

el-oso commented 3 years ago

Hmmm... Actually I would also benefit from this functionality. I have some XML Schemas that are generated by other people and would be great to automatically create readers and writers based on those.

goretkin commented 3 years ago

What would the different types enable you to do, as opposed to using a Dict or NamedTuple or another single type?

Note for example that Julia's own AST representation for its syntax uses (for non-leaf nodes) the same type Expr. Or another example: https://github.com/yurivish/Hyperscript.jl/blob/c780f6dcd95fbf8931c7afc00499a8436075ae6c/src/Hyperscript.jl#L79-L84

GitHub
yurivish/Hyperscript.jl
Hyperscript: A lightweight DOM representation for Julia - yurivish/Hyperscript.jl