/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * XML projection — nested mixed-content with attributes. * * Each component is one element. The element's _direct text node_ is the component's own value * (e.g. `Paris…` — "Paris" is the locality's text). Children are nested as * sub-elements representing geographic / structural containment. * * Attributes: * * - `conf` — aggregated confidence in [0, 1], two decimal places. * - `start` / `end` — character offsets in the raw input. Preserves source order alongside the * containment-derived element order. * - `src` — provenance for the assertion. Formatted as `:` when both fields are * present on the node, `` when only the broad category is set, omitted when neither * is. Phase 4.1 surfaces classifier provenance (`rule:whos_on_first`, `neural:v0.3.1-en-us`); * Phase 4.3 overlays resolver provenance (`resolver:wof-admin:101751119`). * - `lat` / `lon` — resolver-supplied centroid (Phase 4.3). Emitted only when both are set. * - `place` — resolver-supplied normalized place URI like `wof:101751119` (Phase 4.3). Emitted only * when `node.placeID` is set; distinct from `src` so callers that want the bare place id * without the vendor prefix have a direct attribute to read. * - Root `
` carries `raw` — the full input string for round-trip. * * ⚠ DOM gotcha: `element.textContent` on a mixed-content node returns the concatenation of all * descendant text (parent value + children values). Use `Array.from(el.childNodes).filter(n => * n.nodeType === 3).map(n => n.nodeValue).join('').trim()` or XPath `text()` to get just the * parent's own value. Documented in the package README. */ import type { AddressTree } from "./types.ts"; export interface SerializeXMLOpts { /** * Pretty-print with line breaks and indentation. Default true. */ pretty?: boolean; /** * Include `conf` attribute on every component. Default true. */ includeConf?: boolean; /** * Include `start` + `end` char-offset attributes. Default true. */ includeOffsets?: boolean; /** * Include `src` provenance attribute when the node carries source info. Default true. */ includeSrc?: boolean; /** * Include `lat` + `lon` resolver-supplied centroid attrs when set on the node. Default true. */ includeGeo?: boolean; /** * Include `place` resolver-supplied normalized place URI when set. Default true. */ includePlace?: boolean; /** * Include `` child elements for each runner-up resolver candidate on the node. When set + * node.alternatives is populated, each runner-up is emitted as a self-closing element with `place`, `name`, `lat`, * `lon`, `score` attributes. Default false — keeps output libpostal-compat when not explicitly requested * (Springfield-class disambiguation surfaces only when the caller asks). */ includeAlternatives?: boolean; /** * Emit `` elements for the all-O runs no node covers — the input the model left * unclassified (#493 lossless decomposition). Interleaved with the root components in source order, so the * `
` children tile the raw input exactly. Default false — keeps output libpostal-compat / the existing shape * when not explicitly requested (same posture as {@link includeAlternatives}). */ includeUnknown?: boolean; } /** * Project an `AddressTree` to nested XML with optional confidence/offset attributes. */ export declare function decodeAsXML(tree: AddressTree, opts?: SerializeXMLOpts): string; //# sourceMappingURL=serialize-xml.d.ts.map