UNPKG

typesxml

Version:

Open source XML library written in TypeScript

104 lines 3.37 kB
"use strict"; /******************************************************************************* * 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 *******************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.GrammarType = exports.ValidationResult = exports.ValidationWarning = exports.ValidationError = exports.ValidationContext = exports.AttributeUse = exports.AttributeInfo = void 0; // Unified attribute information 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; } } exports.AttributeInfo = AttributeInfo; var AttributeUse; (function (AttributeUse) { AttributeUse["REQUIRED"] = "required"; AttributeUse["OPTIONAL"] = "optional"; AttributeUse["IMPLIED"] = "implied"; AttributeUse["FIXED"] = "fixed"; AttributeUse["PROHIBITED"] = "prohibited"; })(AttributeUse || (exports.AttributeUse = AttributeUse = {})); // Validation context class ValidationContext { childrenNames; attributes; parent; attributeOnly; constructor(childrenNames, attributes, parent, attributeOnly = false) { this.childrenNames = childrenNames; this.attributes = attributes; this.parent = parent; this.attributeOnly = attributeOnly; } } exports.ValidationContext = ValidationContext; // Validation result class ValidationError { message; location; constructor(message, location) { this.message = message; this.location = location; } } exports.ValidationError = ValidationError; class ValidationWarning { message; location; constructor(message, location) { this.message = message; this.location = location; } } exports.ValidationWarning = ValidationWarning; 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; } } exports.ValidationResult = ValidationResult; // Grammar type enumeration var GrammarType; (function (GrammarType) { GrammarType["DTD"] = "dtd"; GrammarType["XML_SCHEMA"] = "xmlschema"; GrammarType["RELAX_NG"] = "relaxng"; GrammarType["NONE"] = "none"; })(GrammarType || (exports.GrammarType = GrammarType = {})); //# sourceMappingURL=Grammar.js.map