pub fn form_dom_driven_repeat_instance_replication(
som: &str,
form_dom_instance_count: usize,
template_default_count: usize,
) -> FormDomReplicationDecisionExpand description
Apply rule form_dom_driven_repeat_instance_replication.
Inputs:
som— SOM-style name / SOM path of the repeating subform group.form_dom_instance_count— number of<subform name="X">siblings recorded in the saved form DOM for this name.template_default_count— number of instances the template’s initial expansion produced (data-driven count after<occur>clamping).
Output:
clones_to_add=max(0, form_dom_count - template_default_count)whentemplate_default_count > 0. Returns 0 when the template produced no instance at all (the caller’s existing guard) or when the form DOM does not exceed the default count.
§Trace anchor
(occur, subform_materialised_from_data) fires when the rule adds
at least one clone, with count set to the final instance count
(form_dom_instance_count). This reuses the existing M1.5 Reason
tag — the rule reports each “instance materialised from form-DOM
data” outcome under the canonical XFA Reason vocabulary. Silence
on zero-clones is intentional: the rule had no value-add over the
template default.
§Behaviour preservation
Bit-identical to the inline expression in
pdf_xfa::flatten::apply_form_dom_presence:
if xml_count > existing_count && existing_count > 0 {
let clones_needed = xml_count - existing_count;
// … clone subtree clones_needed times …
trace_sites::occur(gname, SubformMaterialisedFromData, xml_count);
}The rule wraps the if/clones_needed/trace block into a typed
decision. The caller still owns the actual clone_subtree /
form_children.insert(…) mutations.