import { XmlDocument } from './XmlNodes'; export interface ParseOptions { /** Preserve whitespace-only text nodes (default: false) */ preserveWhitespace?: boolean; /** Resolve namespace URIs from prefix declarations (default: true) */ resolveNamespaces?: boolean; /** * Maximum element nesting depth – prevents stack overflow on * pathologically deep documents (default: 500). */ maxDepth?: number; /** * Maximum number of attributes allowed on a single element (default: 256). */ maxAttributes?: number; /** * Maximum text node character length (default: 10_000_000). */ maxTextLength?: number; /** * Maximum total number of nodes (elements + text) in the document (default: 1_000_000). */ maxNodeCount?: number; /** * Additional named entity map used during entity decoding. * Useful for documents that declare custom entities in the DTD subset. */ entityMap?: Readonly>; /** * When true (default), parse declarations from the * internal DTD subset and use them for entity expansion (G11). * External SYSTEM/PUBLIC entities are always blocked (XXE prevention). */ expandDtdEntities?: boolean; /** * G19 — Override the declared encoding. * When set, the parser trusts this encoding name instead of the value in * the XML declaration. Useful when the caller has already transcoded the * input (e.g. via TextDecoder) but still wants the encoding stored on the * resulting XmlDocument. */ encoding?: string; } export declare class XmlParser { private r; private opts; private ns; private _depth; private _nodeCount; /** G10: reference to the current document for xmlId registration */ private _doc; /** G10: xml:base stack — each entry is the resolved base URI at that depth */ private _baseUriStack; constructor(options?: ParseOptions); parse(input: string): XmlDocument; private parseXmlDeclaration; private parseComment; private parsePI; private parseDoctype; /** * G11: Parse and declarations * from the internal DTD subset. * - Only general entities (no %) are supported. * - SYSTEM/PUBLIC entities are blocked (XXE prevention). * - Nested entity references within values are NOT expanded (no recursion). * - Values exceeding maxTextLength are silently skipped. * NP0-18 fix: limit total entity count and aggregate size to prevent memory exhaustion. */ private _parseDtdEntities; private parseElement; private parseChildren; private parseAttribute; private parseAttributeValue; private parseText; private parseCData; /** * Parse an XML Name per XML 1.0 §2.3. * * NameStartChar: ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | * [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | ... * * For the common case (ASCII names) this is very fast; Unicode names are * handled by the fallback regex. */ /** * Parse an XML Name. * item 4: Uses consumePattern with a sticky regex for a single-pass scan * instead of per-character callback — significantly faster on long element names. */ private parseName; /** Consume characters until `stop` sequence; does NOT consume `stop`. */ private consumeUntil; } /** * Convenience function – parse an XML string and return an XmlDocument. * Throws an XmlError if the document has no root element (strict well-formedness). */ export declare function parseXml(input: string, options?: ParseOptions): XmlDocument; //# sourceMappingURL=XmlParser.d.ts.map