/** * NamespaceEngine (G35) * ────────────────────── * Centralised namespace resolution engine for xml-xsd-engine v1.4. * * Responsibilities * ──────────────── * • Maintains a scoped prefix→URI mapping stack (push/pop per element) * • Resolves QNames to { namespaceURI, localName, prefix } * • Enforces XML Namespaces 1.0 constraints: * - "xml" prefix must map to http://www.w3.org/XML/1998/namespace * - "xmlns" prefix is reserved and must not be declared * - Empty prefix maps to the default namespace (or "" if undeclared) * • Validates prefix declarations as they are pushed * • Exposes helpers used by the parser, validator, XPath engine, and * schema compiler * * The engine is intentionally stateful — one instance lives for the * duration of a single document parse or validation run. */ export declare const NS_XML = "http://www.w3.org/XML/1998/namespace"; export declare const NS_XMLNS = "http://www.w3.org/2000/xmlns/"; export declare const NS_XSD = "http://www.w3.org/2001/XMLSchema"; export declare const NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"; export interface ResolvedName { /** Resolved namespace URI, or '' for no-namespace */ namespaceURI: string; /** Local part (after colon, or full name if no prefix) */ localName: string; /** Prefix used in the source, or '' */ prefix: string; /** Original QName as it appeared in the source */ qname: string; } export interface NamespaceDeclaration { /** '' = default namespace */ prefix: string; /** The namespace URI being declared */ uri: string; } export declare class NamespaceEngine { private stack; private current; /** Set of all namespace URIs seen during processing — useful for diagnostics */ readonly seenURIs: Set; constructor(); /** * Enter a new namespace scope, declaring the given prefix→URI pairs. * Call once per element open tag, before resolving the element name. */ pushScope(declarations: NamespaceDeclaration[]): void; /** * Leave the current element's namespace scope. * Must be called once per pushScope. */ popScope(): void; /** * Current nesting depth (number of pushScope calls minus popScope calls). */ get depth(): number; /** * Resolve a QName (e.g. "xs:element", "book", ":bad") in the current scope. * * Throws NS_UNDECLARED_PREFIX if the prefix cannot be found. * Throws NS_INVALID_QNAME if the QName is structurally invalid. */ resolveQName(qname: string, isAttribute?: boolean): ResolvedName; /** * Attempt to resolve a QName; returns null instead of throwing if the * prefix is not declared. Useful for optional namespace-aware matching. */ tryResolveQName(qname: string, isAttribute?: boolean): ResolvedName | null; /** * Resolve a prefix to its currently-in-scope URI. * Returns undefined if not declared. */ resolvePrefix(prefix: string): string | undefined; /** * Return the currently active default namespace URI, or '' if none. */ get defaultNamespace(): string; /** * Build a namespace-qualified lookup key of the form `{uri}localName`. * Used for consistent schema/element lookups throughout the engine. */ static buildKey(namespaceURI: string, localName: string): string; /** * Parse a key of the form `{uri}local` or `local` back into parts. */ static parseKey(key: string): { namespaceURI: string; localName: string; }; /** * Given a namespace URI and a preferred prefix, return the prefix that * should be used in the current scope (may be the preferred one, or one * already in scope). Registers a new declaration if needed. * * Used by the serializer to control namespace prefix output (G20). */ getOrAllocatePrefix(uri: string, preferredPrefix: string): { prefix: string; newDeclaration: NamespaceDeclaration | null; }; private _validateDeclaration; private _nsError; } //# sourceMappingURL=NamespaceEngine.d.ts.map