Skip to content

3.5.0

Choose a tag to compare

@plutext plutext released this 20 Oct 04:00
· 26 commits to master since this release

The unmarshaller can now report, for each typed object, the source element it was read from. This is the counterpart of 3.4.0's marshal-side onElement.

context.createUnmarshaller({ onElement: function (element, value) { /* ... */ } })

When it fires. Once for every element read as a typed object, after the object is complete: its attributes and content are read and its PARENT is set. Children are therefore reported before their parent.

  • An xsi:type element is reported once, as its derived type.
  • element is the source node itself, in its own document, so lookupNamespaceURI sees its ancestors' declarations.

Not reported: elements holding a simple value (their owner is), { name, value } wrappers (their value is), and wildcard DOM content. The typings now promise that wildcard DOM content is the source node itself, not a copy. If unmarshalling throws, the calls already made stand.

Why. @docx4j/generated-objects-ts CR-011 records, for each typed mc:Choice, the bindings of the prefixes its Requires names. The typed tree keeps no namespace declarations, so those bindings are otherwise lost on a round trip.

What a consumer must do. Nothing: with the option unset, behaviour and output are unchanged, and the cost is not measurable. One edge: the option has the same name as the marshal-side callback. A caller that passes one options object to both createMarshaller and createUnmarshaller, or unmarshals from a context derived with onElement, now also gets unmarshal reports.

Change request: docs/change-requests/jsonix-CR-008-unmarshal-on-element.md