typesxml
Version:
Open source XML library written in TypeScript
88 lines (87 loc) • 5.06 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 { Catalog } from "./Catalog.js";
import { XMLElement } from "./XMLElement.js";
type ElementInfo = {
element: XMLElement;
namespace?: string;
localName: string;
};
export type AttributeDefault = {
localName: string;
namespace?: string;
lexicalName: string;
value: string;
};
type AttributeDefinitionInfo = {
element: XMLElement;
namespace?: string;
};
export declare class XMLSchemaParser {
private static instance;
private static readonly XML_NS;
private static readonly IGNORED_NAMESPACES;
catalog: Catalog | undefined;
private schemaCache;
private schemaProcessingStack;
visitedSchemas: Set<string>;
complexTypeDefinitions: Map<string, XMLElement>;
redefineOriginals: Map<string, XMLElement>;
attributeGroupDefinitions: Map<string, XMLElement>;
attributeDefinitions: Map<string, AttributeDefinitionInfo>;
elementDefinitions: Map<string, ElementInfo>;
simpleTypeDefinitions: Map<string, XMLElement>;
collectedDefaults: Map<string, Map<string, AttributeDefault>>;
complexTypeDefaultCache: Map<string, Map<string, AttributeDefault>>;
attributeGroupDefaultCache: Map<string, Map<string, AttributeDefault>>;
parsedSchemaRoots: Array<XMLElement>;
protected constructor(catalog?: Catalog);
static getInstance(catalog?: Catalog): XMLSchemaParser;
collectDefaultAttributes(schemaPath: string): Map<string, Map<string, AttributeDefault>>;
protected resetWorkingState(): void;
private injectXmlNamespaceAttributes;
protected cloneDefaults(source: Map<string, Map<string, AttributeDefault>>): Map<string, Map<string, AttributeDefault>>;
protected cloneAttributeDefaultMap(source: Map<string, AttributeDefault>): Map<string, AttributeDefault>;
protected computeDefaultsForElement(info: ElementInfo): Map<string, AttributeDefault>;
protected collectDefaultsFromElementDeclaration(element: XMLElement, accumulator: Map<string, AttributeDefault>, visitedTypes: Set<string>, namespace?: string): void;
protected collectDefaultsFromComplexType(typeElement: XMLElement, accumulator: Map<string, AttributeDefault>, visitedTypes: Set<string>, namespace?: string): void;
protected collectDefaultsFromAttributeContainer(container: XMLElement, accumulator: Map<string, AttributeDefault>, visitedTypes: Set<string>, namespace?: string): void;
protected recordAttributeDefault(attributeElement: XMLElement, accumulator: Map<string, AttributeDefault>, namespace?: string): void;
protected resolveTypeDefaults(typeName: string, namespace?: string, visitedTypes?: Set<string>): Map<string, AttributeDefault>;
protected resolveAttributeGroupDefaults(groupName: string, namespace?: string, visitedGroups?: Set<string>): Map<string, AttributeDefault>;
protected lookupComplexType(typeName: string): XMLElement | undefined;
protected lookupOriginalComplexType(typeName: string): XMLElement | undefined;
protected lookupAttributeGroup(groupName: string): XMLElement | undefined;
protected lookupAttributeGroupWithNamespace(groupName: string): {
element: XMLElement;
namespace: string | undefined;
} | undefined;
protected lookupComplexTypeWithNamespace(typeName: string): {
element: XMLElement;
namespace: string | undefined;
} | undefined;
protected lookupAttribute(name: string, namespace?: string): AttributeDefinitionInfo | undefined;
protected mergeMaps(target: Map<string, AttributeDefault>, source: Map<string, AttributeDefault>): void;
protected walkSchema(schemaPath: string, includingTargetNamespace?: string | null): void;
protected processSchemaReferences(schemaElement: XMLElement, baseDir: string): void;
protected applyRedefinitions(redefineElement: XMLElement, targetNamespace?: string): void;
static shouldIgnoreNamespace(namespaceUri: string): boolean;
protected registerSchemaComponents(schemaElement: XMLElement, targetNamespace?: string): void;
protected resolveReference(location: string | undefined, baseDir: string, namespaceValue?: string): string | undefined;
protected normalizePath(location: string): string;
protected getLocalName(name: string): string;
protected buildElementKey(name: string, namespace?: string): string;
protected buildTypeKey(name: string, namespace?: string): string;
protected buildAttributeKey(name: string, namespace?: string): string;
protected setAttributeDefault(target: Map<string, AttributeDefault>, value: AttributeDefault): void;
}
export {};