UNPKG

typesxml

Version:

Open source XML library written in TypeScript

42 lines (41 loc) 1.82 kB
/******************************************************************************* * Copyright (c) 2023-2026 Maxprograms. * * This program and the accompanying materials * are made available under the terms of the Eclipse License 1.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/epl-v10.html * * Contributors: * Maxprograms - initial API and implementation *******************************************************************************/ import { Readable } from "node:stream"; import { ParseSourceOptions, StreamParseOptions } from "./SAXParser.js"; import { XMLDocument } from "./XMLDocument.js"; /** * Generates the canonical XML representation defined by the W3C XML Test Suite. * * Canonicalization rules: * - Attribute order is lexical (Unicode code point order). * - Character data is escaped using the Datachar productions (&amp;, &lt;, &gt;, &quot;, &#9;, &#10;, &#13;). * - CDATA sections are treated as their character content. * - Comments and document type declarations are omitted. * - Processing instructions are preserved in document order with their data escaped as Datachar. */ export declare class XMLCanonicalizer { private document; parseFile(path: string, encoding?: BufferEncoding): void; parseString(xml: string, options?: ParseSourceOptions): void; parseStream(stream: Readable, options?: StreamParseOptions): Promise<void>; setDocument(document: XMLDocument): void; getDocument(): XMLDocument | undefined; toString(): string; private renderDocument; private renderTopLevelNode; private renderElement; private renderProcessingInstruction; private getNodeValue; private escapeData; private escapeProcessingInstructionData; private isWhitespaceOnly; }