Ootempl.Xml.Normalizer (ootempl v0.3.0)

XML normalization for fragmented placeholders in Word documents.

Microsoft Word often fragments placeholders across multiple XML runs and text elements due to spell-checking, grammar-checking, formatting changes, or editing history. This module normalizes the XML by collapsing fragmented placeholders into single text runs while preserving intentional formatting.

Example

Fragmented placeholder:

<w:r><w:t>Hello {{</w:t></w:r>
<w:proofErr w:type="gramStart"/>
<w:r><w:t>person.first</w:t></w:r>
<w:proofErr w:type="gramEnd"/>
<w:r><w:t>_name}}, how are you?</w:t></w:r>

After normalization:

<w:r><w:t>Hello {{person.first_name}}, how are you?</w:t></w:r>

Usage

{:ok, xml_doc} = Ootempl.Xml.parse(xml_string)
normalized_doc = Ootempl.Xml.Normalizer.normalize(xml_doc)
{:ok, output} = Ootempl.Xml.serialize(normalized_doc)

Summary

Functions

Normalizes an XML document by collapsing fragmented placeholders.

Functions

normalize(xml_node)

@spec normalize(Ootempl.Xml.xml_node()) :: Ootempl.Xml.xml_node()

Normalizes an XML document by collapsing fragmented placeholders.

Recursively traverses the XML tree and normalizes all paragraphs that contain fragmented placeholders.

Parameters

  • xml_node - An xmerl XML element or text node

Returns

  • The normalized XML node

xmlNamespace(args \\ [])

(macro)

xmlNamespace(record, args)

(macro)