Closed aminya closed 5 years ago
AML, that automatically creates/extracts HTML/XML files from Julia types! Actually MusicXML.jl
was my inspiration for that project.
Now that AML is getting better and better, I will take the MusicXML.jl backend to AML, which is much better, and allows fast and compact development.
For example instead of https://github.com/JuliaMusic/MusicXML.jl/blob/b1f01d6fd3343ae3a7125d376701e15ee71ebb9b/src/MusicXML.jl#L85:
@aml struct Scoreinstrument "score-instrument"
name::String, "name"
ID::String, a"id"
end
, AML will generate xml constructors and extractors automatically!
So AML will generate all of this from the previous definition:
struct Scoreinstrument
name::String
ID::String
xml::Node
end
# xml constructor
function Scoreinstrument(name,ID)
xml = ElementNode("score-instrument")
addelement!(xml, "instrument-name", string(name))
xml["id"] = ID * "-I1"
return Scoreinstrument(name, ID, xml)
end
# xml extractor
function Scoreinstrument(xml::Node)
name = findfirstcontent("/instrument-name",xml)
ID = xml["id"][end-3:end]
return Scoreinstrument(name, ID, xml)
end
Scoreinstrument(x::Scoreinstrument) = Scoreinstrument(x.xml)
Scoreinstrument(n::Nothing) = nothing
By doing this the number of lines of codes is almost reduced to half.
Add AML as a dependency and backend and use its
@aml
keyword for the definition of the types. https://github.com/aminya/AML.jl