typesxml
Version:
Open source XML library written in TypeScript
188 lines • 5.35 kB
JavaScript
"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.SchemaElementDecl = void 0;
const SchemaContentModel_js_1 = require("./SchemaContentModel.js");
const SchemaTypeValidator_js_1 = require("./SchemaTypeValidator.js");
class SchemaElementDecl {
name;
namespace;
contentModel;
attributeDecls;
anyAttribute = false;
anyAttributeNamespace = '##any';
anyAttributeProcessContents = 'strict';
anyAttributeOwnerNs;
anyAttributeExcludedNamespaces;
simpleType;
textFacets;
declaredTypeName;
abstract = false;
blockConstraints = new Set();
finalConstraints = new Set();
nillable = false;
unionMemberTypes;
unionAlternatives;
listItemType;
identityConstraints;
fixedValue;
defaultValue;
qualified = true;
constructor(name, namespace, contentModel) {
this.name = name;
this.namespace = namespace;
this.contentModel = contentModel !== undefined ? contentModel : SchemaContentModel_js_1.SchemaContentModel.any();
this.attributeDecls = new Map();
}
getName() {
return this.name;
}
getNamespace() {
return this.namespace;
}
getContentModel() {
return this.contentModel;
}
setContentModel(model) {
this.contentModel = model;
}
addAttributeDecl(decl) {
this.attributeDecls.set(decl.getName(), decl);
}
addAttributeDeclWithKey(name, decl) {
this.attributeDecls.set(name, decl);
}
getAttributeDecl(name) {
return this.attributeDecls.get(name);
}
getAttributeDecls() {
return this.attributeDecls;
}
setSimpleType(type) {
this.simpleType = type;
}
getSimpleType() {
return this.simpleType;
}
setTextFacets(facets) {
this.textFacets = facets;
}
validateText(value) {
if (!this.textFacets) {
return true;
}
return SchemaTypeValidator_js_1.SchemaTypeValidator.validateFacets(value, this.textFacets, this.simpleType);
}
hasTextFacets() {
return this.textFacets !== undefined;
}
setAnyAttribute(namespace = '##any', processContents = 'strict', ownerNs, excludedNamespaces) {
this.anyAttribute = true;
this.anyAttributeNamespace = namespace;
this.anyAttributeProcessContents = processContents;
this.anyAttributeOwnerNs = ownerNs;
this.anyAttributeExcludedNamespaces = excludedNamespaces;
}
allowsAnyAttribute() {
return this.anyAttribute;
}
getAnyAttributeNamespace() {
return this.anyAttributeNamespace;
}
getAnyAttributeProcessContents() {
return this.anyAttributeProcessContents;
}
getAnyAttributeOwnerNs() {
return this.anyAttributeOwnerNs;
}
getAnyAttributeExcludedNamespaces() {
return this.anyAttributeExcludedNamespaces;
}
setDeclaredTypeName(typeName) {
this.declaredTypeName = typeName;
}
getDeclaredTypeName() {
return this.declaredTypeName;
}
setAbstract(value) {
this.abstract = value;
}
isAbstractElement() {
return this.abstract;
}
setBlockConstraints(constraints) {
this.blockConstraints = constraints;
}
getBlockConstraints() {
return this.blockConstraints;
}
setFinalConstraints(constraints) {
this.finalConstraints = constraints;
}
getFinalConstraints() {
return this.finalConstraints;
}
setNillable(value) {
this.nillable = value;
}
isNillable() {
return this.nillable;
}
setUnionMemberTypes(types) {
this.unionMemberTypes = types;
}
getUnionMemberTypes() {
return this.unionMemberTypes;
}
setUnionAlternatives(alts) {
this.unionAlternatives = alts.slice();
}
getUnionAlternatives() {
return this.unionAlternatives;
}
setListItemType(type) {
this.listItemType = type;
}
getListItemType() {
return this.listItemType;
}
addIdentityConstraint(constraint) {
if (!this.identityConstraints) {
this.identityConstraints = [];
}
this.identityConstraints.push(constraint);
}
getIdentityConstraints() {
return this.identityConstraints;
}
setFixedValue(value) {
this.fixedValue = value;
}
getFixedValue() {
return this.fixedValue;
}
setDefaultValue(value) {
this.defaultValue = value;
}
getDefaultValue() {
return this.defaultValue;
}
setQualified(value) {
this.qualified = value;
}
isQualified() {
return this.qualified;
}
}
exports.SchemaElementDecl = SchemaElementDecl;
//# sourceMappingURL=SchemaElementDecl.js.map