rescript-iof-xml
v0.0.5
Published
IOF XML 3.0 types and parser for ReScript
Readme
rescript-iof-xml
IOF XML 3.0 types and parser for ReScript. Covers CompetitorList, EntryList, StartList, CourseData, ResultList, and EventList document types.
Types and their fields are documented based on the official IOF XML 3.0 XSD. Hover any type or function in your editor to see the relevant XSD documentation.
API docs
Full API reference is available at rescript-iof-xml.pages.dev/api.
Installation
npm install --save-exact rescript-iof-xmlAdd to rescript.json:
{
"dependencies": ["rescript-iof-xml"]
}Usage
let xml = "<EntryList>...</EntryList>"
switch IofXml.EntryList.parse(xml) {
| Ok(entryList) => Console.log(entryList)
| Error(msg) => Console.error(msg)
}Highlights
- ResultList — parses
PersonResult,TeamResult, andTeamMemberResult(relay).statusfields use typed variant unions (resultStatus,splitTimeStatus,resultListStatus) instead of raw strings. - Multi-race —
PersonResult.resultsis an array (one entry per race leg), andClassResult.coursesis an array. - Organisations —
countryis typed as{code, name}instead of a plain string. - Persons —
sexis a typed variant (Male | Female) with@as("M")/@as("F")for correct wire values. - EventorExtensions — opt-in helper for reading the Eventor-specific data carried in
<Extensions>elements (namespacehttp://eventor.orientering.se/iofxmlextensions) emitted by the Eventor REST API's/.../iofxmlendpoints. CallEventorExtensions.fromElement(eventEl)on any<Event>or<Race>XML element to get a typed record witheventRaceId,startListExists,resultListExists,disciplines(an array — events/races can accommodate multiple),lightConditionandattributes(custom Eventor event attributes, each with anidandvalue).
