UNPKG

typesxml

Version:

Open source XML library written in TypeScript

96 lines 2.89 kB
/******************************************************************************* * 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 *******************************************************************************/ // Unified attribute information export class AttributeInfo { name; datatype; use; defaultValue; fixedValue; namespace; constructor(name, datatype, use, defaultValue, fixedValue, namespace) { this.name = name; this.datatype = datatype; this.use = use; this.defaultValue = defaultValue; this.fixedValue = fixedValue; this.namespace = namespace; } } export var AttributeUse; (function (AttributeUse) { AttributeUse["REQUIRED"] = "required"; AttributeUse["OPTIONAL"] = "optional"; AttributeUse["IMPLIED"] = "implied"; AttributeUse["FIXED"] = "fixed"; AttributeUse["PROHIBITED"] = "prohibited"; })(AttributeUse || (AttributeUse = {})); // Validation context export class ValidationContext { childrenNames; attributes; parent; attributeOnly; constructor(childrenNames, attributes, parent, attributeOnly = false) { this.childrenNames = childrenNames; this.attributes = attributes; this.parent = parent; this.attributeOnly = attributeOnly; } } // Validation result export class ValidationError { message; location; constructor(message, location) { this.message = message; this.location = location; } } export class ValidationWarning { message; location; constructor(message, location) { this.message = message; this.location = location; } } export class ValidationResult { isValid; errors; warnings; constructor(isValid, errors = [], warnings = []) { this.isValid = isValid; this.errors = errors; this.warnings = warnings; } static success() { return new ValidationResult(true); } static error(message, location) { return new ValidationResult(false, [new ValidationError(message, location)]); } static warning(message, location) { const result = new ValidationResult(true); result.warnings.push(new ValidationWarning(message, location)); return result; } } // Grammar type enumeration export var GrammarType; (function (GrammarType) { GrammarType["DTD"] = "dtd"; GrammarType["XML_SCHEMA"] = "xmlschema"; GrammarType["RELAX_NG"] = "relaxng"; GrammarType["NONE"] = "none"; })(GrammarType || (GrammarType = {})); //# sourceMappingURL=Grammar.js.map