added xml unit component
This commit is contained in:
@ -1,23 +1,46 @@
|
|||||||
export abstract class XmlComponent {
|
export abstract class BaseXmlComponent {
|
||||||
protected root: Array<XmlComponent>;
|
|
||||||
protected rootKey: string;
|
protected rootKey: string;
|
||||||
|
|
||||||
constructor(rootKey: string) {
|
constructor(rootKey: string) {
|
||||||
this.root = new Array<XmlComponent>();
|
|
||||||
this.rootKey = rootKey;
|
this.rootKey = rootKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceKey() {
|
abstract replaceKey(): void;
|
||||||
console.log(this.rootKey);
|
}
|
||||||
console.log(this.root);
|
|
||||||
|
export abstract class XmlComponent extends BaseXmlComponent {
|
||||||
|
protected root: Array<BaseXmlComponent>;
|
||||||
|
|
||||||
|
constructor(rootKey: string) {
|
||||||
|
super(rootKey);
|
||||||
|
this.root = new Array<BaseXmlComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceKey(): void {
|
||||||
|
//console.log(this.rootKey);
|
||||||
|
//console.log(this.root);
|
||||||
if (this.root !== undefined) {
|
if (this.root !== undefined) {
|
||||||
this.root.forEach(root => {
|
this.root.forEach(root => {
|
||||||
root.replaceKey();
|
root.replaceKey();
|
||||||
});
|
});
|
||||||
|
this[this.rootKey] = this.root;
|
||||||
|
delete this.root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class XmlUnitComponent extends BaseXmlComponent {
|
||||||
|
protected root: string;
|
||||||
|
|
||||||
|
constructor(rootKey: string) {
|
||||||
|
super(rootKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceKey(): void {
|
||||||
|
if (this.root !== undefined) {
|
||||||
|
this[this.rootKey] = this.root;
|
||||||
|
delete this.root;
|
||||||
}
|
}
|
||||||
this[this.rootKey] = this.root;
|
|
||||||
//Object(this)[this.rootKey]
|
|
||||||
delete this.root;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,15 +101,10 @@ export class Attributes extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Text extends XmlComponent {
|
export class Text extends XmlUnitComponent {
|
||||||
private t: string;
|
|
||||||
|
|
||||||
xmlKeys = {
|
|
||||||
t: 'w:t'
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(text: string) {
|
constructor(text: string) {
|
||||||
super("w:t");
|
super("w:t"); //need special xml component
|
||||||
this.t = text;
|
this.root = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user