xml-helper.d.tsā¢3.83 kB
import { DefaultAttribute, HelperElement, ModifyXmlCallback, OverrideAttribute, RelationshipAttribute, XmlDocument, XmlElement } from '../types/xml-types';
import { GetRelationshipsCallback, Target } from '../types/types';
import IArchive from '../interfaces/iarchive';
import { ContentTypeExtension } from '../enums/content-type-map';
export declare class XmlHelper {
static modifyXmlInArchive(archive: IArchive, file: string, callbacks: ModifyXmlCallback[]): Promise<void>;
static getXmlFromArchive(archive: IArchive, file: string): Promise<XmlDocument>;
static writeXmlToArchive(archive: IArchive, file: string, xml: XmlDocument): void;
static appendIf(element: HelperElement): Promise<XmlElement | boolean>;
static append(element: HelperElement): Promise<XmlElement>;
static removeIf(element: HelperElement): Promise<XmlElement[]>;
static getNextRelId(rootArchive: IArchive, file: string): Promise<string>;
static getMaxId(rels: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attribute: string, increment?: boolean, minId?: number): number;
static getRelationshipTargetsByPrefix(archive: IArchive, path: string, prefix: string | string[]): Promise<Target[]>;
static parseRelationTarget(element: XmlElement, prefix?: string): Target;
static targetMatchesRelationship(relType: any, subtype: any, target: any, prefix: any): boolean;
static getTargetsByRelationshipType(archive: IArchive, path: string, type: string): Promise<Target[]>;
static getRelationshipItems(archive: IArchive, path: string, cb: GetRelationshipsCallback, tag?: string): Promise<Target[]>;
static findByAttribute(xml: XmlDocument | Document, tagName: string, attributeName: string, attributeValue: string): boolean;
static replaceAttribute(archive: IArchive, path: string, tagName: string, attributeName: string, attributeValue: string, replaceValue: string, replaceAttributeName?: string): Promise<void>;
static getTargetByRelId(archive: IArchive, relsPath: string, element: XmlElement, type: string): Promise<Target>;
static findByElementCreationId(archive: IArchive, path: string, creationId: string): Promise<XmlElement>;
static findByElementName(archive: IArchive, path: string, name: string): Promise<XmlElement>;
static findByName(doc: Document, name: string): XmlElement;
static findByCreationId(doc: Document, creationId: string): XmlElement;
static findFirstByAttributeValue(nodes: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attributeName: string, attributeValue: string): XmlElement;
static findByAttributeValue(nodes: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attributeName: string, attributeValue: string): XmlElement[];
static createContentTypeChild(archive: IArchive, attributes: OverrideAttribute | DefaultAttribute): HelperElement;
static createRelationshipChild(archive: IArchive, targetRelFile: string, attributes: RelationshipAttribute): HelperElement;
static appendImageExtensionToContentType(targetArchive: IArchive, extension: ContentTypeExtension): Promise<XmlElement | boolean>;
static appendSharedString(sharedStrings: Document, stringValue: string): number;
static insertAfter(newNode: Node, referenceNode: XmlElement): Node;
static sliceCollection(collection: HTMLCollectionOf<XmlElement>, length: number, from?: number): void;
static remove(toRemove: XmlElement): void;
static sortCollection(collection: HTMLCollectionOf<XmlElement>, order: number[], callback?: ModifyXmlCallback): void;
static modifyCollection(collection: HTMLCollectionOf<XmlElement>, callback: ModifyXmlCallback): void;
static modifyCollectionAsync(collection: HTMLCollectionOf<XmlElement>, callback: ModifyXmlCallback): Promise<void>;
static dump(element: XmlDocument | XmlElement): void;
}