# `UOF.Schemas.XML`
[🔗](https://github.com/efcasado/betradar_uof_schemas/blob/main/lib/uof/schemas/xml.ex#L1)

Generic XML -> Ecto embedded schema decoder.

Parses an XML document with `Saxy` and, driven purely by the target schema's
Ecto reflection, builds a (possibly deeply nested) params map that is cast
through the schema's changeset. Because the generated schemas mirror the XSD
nesting, every XML element/attribute name lines up with a schema field name,
so one recursive walk handles all of them.

Call `decode/1` to dispatch on the document's root element against the full
generated registry (`UOF.Schemas.XML.Registry`) — every feed message and API
response decodes through this one entry point. Use `decode/2` only when you
need to override that: pass a schema module to force a known type, or a custom
`root element => module` registry to scope dispatch.

# `decode`

Decode `xml`, dispatching on its root element against the full schema registry.

This is the everyday entry point: it handles every known feed message and API
response. Returns `{:ok, struct}`, `{:error, Ecto.Changeset.t()}`, or
`{:error, {:unknown_message, name}}` for an unrecognised root element.

# `decode`

Decode `xml` against an explicit `target`, overriding the default registry.

`target` selects the schema:

  * a **schema module** — decode into that type (static). Use when the caller
    already knows it and wants to assert it regardless of the root element.
  * a **registry map** of `root element name => schema module` — dispatch on
    the document's root element, scoped to that map.

Returns `{:ok, struct}` or `{:error, Ecto.Changeset.t()}`; with a registry
that has no entry for the root element, `{:error, {:unknown_message, name}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
