isoxml-angular
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
59 lines (58 loc) • 2.66 kB
TypeScript
import { Entity, EntityAttributes, ISOXMLReference, XMLElement } from './types';
import './baseEntities';
import './entities';
import { ExtendedISO11783TaskDataFile } from "./entities/ISO11783TaskDataFile";
import { TAGS } from "./baseEntities/constants";
import { GridGenerator, GridParametersGenerator } from "./entities";
export type ISOXMLManagerOptions = {
rootFolder?: string;
fmisTitle?: string;
fmisURI?: string;
fmisVersion?: string;
version?: number;
gridParamsGenerator?: GridParametersGenerator;
gridGenerator?: GridGenerator;
realm?: string;
};
export declare class ISOXMLManager {
private nextIds;
private originalZip;
private parsingWarnings;
xmlReferences: {
[xmlId: string]: ISOXMLReference;
};
rootElement: ExtendedISO11783TaskDataFile;
filesToSave: {
[filenameWithExtension: string]: (Uint8Array | string);
};
options: ISOXMLManagerOptions;
constructor(options?: ISOXMLManagerOptions);
private parseXmlId;
generateUniqueFilename(xmlTag: TAGS): string;
addFileToSave(data: Uint8Array | string, filenameWithExtension: string): void;
/**
* if "xmlId" is provided:
* - if such reference exists, update its content with "entity" and "fmis"
* - otherwise, generate new reference
* if "xmlId" is not provided, do the following:
* - try to find the "entity" (the same JS object) in references
* - try to find the entity with the same type and "fmisId" if provided
* - if both above failed, create new reference
* Returns undefined if failed to create reference
*/
registerEntity(entity?: Entity, xmlId?: string, fmisId?: string): ISOXMLReference;
createEntityFromXML(tagName: TAGS, xml: XMLElement, internalId?: string): Promise<Entity>;
createEntityFromAttributes<T extends Entity = Entity>(tagName: TAGS, attrs: EntityAttributes): T;
parseISOXMLFile(data: string, dataType: 'text/xml' | 'application/xml'): Promise<void>;
parseISOXMLFile(data: Uint8Array, dataType: 'application/zip'): Promise<void>;
saveISOXML(): Promise<Uint8Array>;
getReferenceByEntity(entity: Entity): ISOXMLReference;
getReferenceByXmlId(xmlId: string): ISOXMLReference;
getEntityByXmlId<T extends Entity>(xmlId: string): T;
getEntitiesOfTag<T extends Entity>(tag: TAGS): T[];
updateOptions(newOptions: ISOXMLManagerOptions): void;
getParsedFile(filenameWithExtension: string, isBinary: true): Promise<Uint8Array>;
getParsedFile(filenameWithExtension: string, isBinary: false): Promise<string>;
addWarning(warning: string): void;
getWarnings(): string[];
}