typesxml
Version:
Open source XML library written in TypeScript
71 lines (70 loc) • 2.85 kB
TypeScript
/*******************************************************************************
* Copyright (c) 2023-2026 Maxprograms.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public 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
*******************************************************************************/
export declare class AttributeInfo {
name: string;
datatype: string;
use: AttributeUse;
defaultValue?: string | undefined;
fixedValue?: string | undefined;
namespace?: string | null | undefined;
constructor(name: string, datatype: string, use: AttributeUse, defaultValue?: string | undefined, fixedValue?: string | undefined, namespace?: string | null | undefined);
}
export declare enum AttributeUse {
REQUIRED = "required",
OPTIONAL = "optional",
IMPLIED = "implied",
FIXED = "fixed",
PROHIBITED = "prohibited"
}
export declare class ValidationContext {
childrenNames: string[];
attributes: Map<string, string>;
parent?: string | undefined;
attributeOnly: boolean;
constructor(childrenNames: string[], attributes: Map<string, string>, parent?: string | undefined, attributeOnly?: boolean);
}
export declare class ValidationError {
message: string;
location?: string | undefined;
constructor(message: string, location?: string | undefined);
}
export declare class ValidationWarning {
message: string;
location?: string | undefined;
constructor(message: string, location?: string | undefined);
}
export declare class ValidationResult {
isValid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
constructor(isValid: boolean, errors?: ValidationError[], warnings?: ValidationWarning[]);
static success(): ValidationResult;
static error(message: string, location?: string): ValidationResult;
static warning(message: string, location?: string): ValidationResult;
}
export declare enum GrammarType {
DTD = "dtd",
XML_SCHEMA = "xmlschema",
RELAX_NG = "relaxng",
NONE = "none"
}
export interface Grammar {
validateElement(element: string, namespace: string, children: string[], text: string): ValidationResult;
validateAttributes(element: string, attributes: Map<string, string>): ValidationResult;
getElementAttributes(element: string): Map<string, AttributeInfo>;
getDefaultAttributes(element: string): Map<string, string>;
resolveEntity(name: string): string | undefined;
getElementTextDefault(element: string): string | undefined;
getGrammarType(): GrammarType;
getTargetNamespaces(): Set<string>;
getNamespaceDeclarations(): Map<string, string>;
}