typesxml
Version:
Open source XML library written in TypeScript
83 lines (82 loc) • 2.05 kB
TypeScript
/*******************************************************************************
* 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 { JsonTokenizer } from "./JsonTokenizer.js";
export interface JsonAttributeDescriptor {
name: string;
value: string;
}
export type JsonNodeEvent = {
type: 'startDocument';
} | {
type: 'endDocument';
} | {
type: 'xmlDeclaration';
version: string;
encoding: string;
standalone?: string;
} | {
type: 'startElement';
name: string;
attributes: Array<JsonAttributeDescriptor>;
} | {
type: 'endElement';
name: string;
} | {
type: 'characters';
value: string;
} | {
type: 'ignorableWhitespace';
value: string;
} | {
type: 'comment';
value: string;
} | {
type: 'processingInstruction';
target: string;
data: string;
} | {
type: 'startCDATA';
} | {
type: 'endCDATA';
} | {
type: 'startDTD';
name: string;
publicId: string;
systemId: string;
} | {
type: 'internalSubset';
declaration: string;
} | {
type: 'endDTD';
} | {
type: 'skippedEntity';
name: string;
};
export declare class JsonNodeReader {
private readonly tokenizer;
private sequenceStarted;
private sequenceEnded;
private expectComma;
private pendingTrailingValidation;
constructor(tokenizer: JsonTokenizer);
readNextEvent(): JsonNodeEvent | undefined;
private ensureSequenceStarted;
private consumeAndFinish;
private consumeDelimiter;
private parseValue;
private parseObject;
private parseArray;
private toEvent;
private readAttributes;
private requireString;
private optionalString;
}