Julia code generation - from DTD or XML Schema to Julia struct


I have some XML data.

Most of these data have a schema to describe them.

Those schema is either a Document type definition (DTD) or an XML Schema (xsd)).

I wonder if Julia have a similar tool than Java JAXB xjc cli tool.

Go have similar tools
xsdgen xsdgen package - aqwari.net/xml/xsdgen - Go Packages
go-xsd https://github.com/metaleap/go-xsd

I can manually convert these schema to Julia code but that’s a quite long and uninteresting task. So if a Julia library could scaffold some Julia code that will be a great feature.

Any suggestion?

Kind regards

That is similar to what I did in AcuteML:

1 Like

Thanks @Amin_Yahyaabadi for pointing to your project but I don’t see how to use it with xsd (XML Schema).

You can see an example of such data schema at
GPX 1.1 Schema Documentation (documentation)
https://www.topografix.com/gpx/1/1/gpx.xsd (xsd file)

You can use AcuteML to generte any complex XML, HTLM file. You don’t need to be restricted to the functionality that XSD provides when you can use Julia code!

AcuteML has elements with custom value checking (instead of the limited choice element in XSD), custom scalar or vector Julia types, custom defined Julia types (instead of the limited XSD types).

See this example: https://github.com/aminya/AcuteML.jl#example---struct-definition

Also, you can check my MusicXML.jl: https://github.com/JuliaMusic/MusicXML.jl/blob/a8841bf8d2e994c51797f6f3e093ab1071c14395/src/MusicXML.jl#L50

If you have a specific example, I can help you to use AcuteML for it.
Also, open issues for any feature that you think is missing, so I can help you with it.

1 Like