Mix.UOF.Schemas.XSD (uof_schemas v0.2.0)

Copy Markdown View Source

A small XSD parser that turns Betradar's .xsd files into a flat intermediate representation (a list of ComplexTypes plus the root elements), suitable for code generation.

It deliberately supports only the XSD subset Betradar uses: xs:complexType, xs:sequence/xs:choice/xs:all, xs:element, xs:attribute, and xs:complexContent > xs:extension. Includes are resolved by simply parsing every file handed in and merging the result; duplicate type names are de-duplicated by name.

Summary

Functions

Parse a single XSD file into a flat list of ComplexType/Root nodes.

Parse and merge a list of XSD file paths into {types, roots}.

Filter types to those reachable from root_type_names, following element type references and xs:extension bases. Lets generation be scoped to the endpoints actually in use instead of every complexType in the schema set.

Resolve root element names to their complexType names, using the roots returned by parse_files/1. Raises on an unknown element name (catches typos in a group's allow-list).

Functions

parse_file(path)

Parse a single XSD file into a flat list of ComplexType/Root nodes.

parse_files(paths)

Parse and merge a list of XSD file paths into {types, roots}.

reachable_types(types, root_type_names)

Filter types to those reachable from root_type_names, following element type references and xs:extension bases. Lets generation be scoped to the endpoints actually in use instead of every complexType in the schema set.

root_types(roots, element_names)

Resolve root element names to their complexType names, using the roots returned by parse_files/1. Raises on an unknown element name (catches typos in a group's allow-list).