/** * Reusable utility for collecting raw XML fragments during SAX parsing. * * Many pivot-table xforms need to capture entire sub-trees (extLst, formats, * conditionalFormats, filters, fieldGroup, unknown elements, …) as raw strings * for roundtrip preservation. The pattern — `active` flag, `depth` counter, * `buffer` of string fragments, plus identical `feedOpen` / `feedClose` / * `feedText` logic — was previously copy-pasted across multiple files. * * Usage: * ```ts * const collector = new RawXmlCollector("extLst"); * // In parseOpen, when you see : * collector.start(); // opens with * // For every child open tag while active: * collector.feedOpen(name, attributes); * // For every text node while active: * collector.feedText(text); * // For every close tag while active: * if (collector.feedClose(name)) { ... } // returns true when root tag closed * // Retrieve result: * collector.result; // joined XML string * ``` */ declare class RawXmlCollector { /** Tag name that this collector captures (e.g. "extLst", "formats"). */ rootTag: string; /** Whether the collector is currently capturing. */ active: boolean; /** Nesting depth *within* the root element (0 = direct children). */ private depth; /** String fragments being accumulated. */ private buffer; /** Index of the last open-tag entry in the buffer (for self-closing collapse). */ private lastOpenIndex; constructor(rootTag: string); /** * Begin collecting. Pushes the opening root tag (with optional attributes) * and resets depth. * * @param attributes - Attributes on the root element (may be undefined/null). */ start(attributes?: Record | null): void; /** * Begin collecting with a dynamically determined root tag. * Used for catch-all unknown element collectors where the tag name * is not known at construction time. */ startAs(rootTag: string, attributes?: Record | null): void; /** * Reset the collector to its initial idle state. */ reset(): void; /** * Feed an open-tag event. Must only be called while `active` is true. */ feedOpen(name: string, attributes?: Record | null): void; /** * Feed a text-node event. Must only be called while `active` is true. */ feedText(text: string): void; /** * Feed a close-tag event. * * @returns `true` when the **root** close tag has been received (collector * deactivates itself and the result is ready). `false` for any * nested close tag. */ feedClose(name: string): boolean; /** The collected XML string. Only meaningful after `feedClose` returns true. */ get result(): string; } /** * Serialize an attributes object to an XML attribute string. * `null`, `undefined`, and empty objects produce an empty string. */ declare function serializeAttributes(attributes?: Record | null): string; export { RawXmlCollector, serializeAttributes };