Skip to content

Commit d8526e0

Browse files
author
ali.asadi.dev
committed
replace xml-js package with custom xml module
1 parent 9fa334f commit d8526e0

File tree

10 files changed

+936
-43
lines changed

10 files changed

+936
-43
lines changed

package-lock.json

Lines changed: 4 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"https-proxy-agent": "^5.0.0",
183183
"node-fetch": "^2.6.1",
184184
"utf8": "^3.0.0",
185-
"xml-js": "^1.6.11"
185+
"sax": "^1.2.4"
186186
},
187187
"__metadata": {
188188
"id": "697a8357-0d3b-4765-8ec9-3a394c9e82c7",

src/models/project-file.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export interface Element {
2222
* The text of element
2323
*/
2424
text?: string;
25+
26+
/**
27+
* The tag is self closing
28+
*/
29+
isSelfClosing?: boolean;
2530
}
2631

2732

src/models/xml.model.ts

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
export interface Attributes {
2+
[key: string]: string | number | undefined
3+
}
4+
5+
export interface DeclarationAttributes {
6+
version?: string | number
7+
encoding?: 'utf-8' | string
8+
standalone?: 'yes' | 'no'
9+
}
10+
11+
export interface ElementCompact {
12+
[key: string]: any
13+
_declaration?: {
14+
_attributes?: DeclarationAttributes
15+
}
16+
_instruction?: {
17+
[key: string]: string
18+
}
19+
_attributes?: Attributes
20+
_cdata?: string
21+
_doctype?: string
22+
_comment?: string
23+
_text?: string | number
24+
}
25+
26+
export interface Element {
27+
declaration?: {
28+
attributes?: DeclarationAttributes
29+
}
30+
instruction?: string
31+
attributes?: Attributes
32+
cdata?: string
33+
doctype?: string
34+
comment?: string
35+
text?: string | number | boolean
36+
type?: string
37+
name?: string
38+
elements?: Array<Element>
39+
}
40+
41+
declare namespace Options {
42+
interface XML2JSON extends XML2JS {
43+
spaces?: number | string
44+
}
45+
46+
interface XML2JS extends ChangingKeyNames, IgnoreOptions {
47+
compact?: boolean
48+
trim?: boolean
49+
sanitize?: boolean
50+
nativeType?: boolean
51+
addParent?: boolean
52+
alwaysArray?: boolean | Array<string>
53+
alwaysChildren?: boolean
54+
instructionHasAttributes?: boolean
55+
captureSpacesBetweenElements?: boolean
56+
doctypeFn?: (value: string, parentElement: object) => void;
57+
instructionFn?: (
58+
instructionValue: string,
59+
instructionName: string,
60+
parentElement: string
61+
) => void;
62+
cdataFn?: (value: string, parentElement: object) => void;
63+
commentFn?: (value: string, parentElement: object) => void;
64+
textFn?: (value: string, parentElement: object) => void;
65+
instructionNameFn?: (
66+
instructionName: string,
67+
instructionValue: string,
68+
parentElement: string
69+
) => void;
70+
elementNameFn?: (value: string, parentElement: object) => void;
71+
attributeNameFn?: (
72+
attributeName: string,
73+
attributeValue: string,
74+
parentElement: string
75+
) => void;
76+
attributeValueFn?: (
77+
attributeValue: string,
78+
attributeName: string,
79+
parentElement: string
80+
) => void;
81+
attributesFn?: (value: string, parentElement: string) => void;
82+
}
83+
84+
interface JS2XML extends ChangingKeyNames, IgnoreOptions {
85+
spaces?: number | string
86+
compact?: boolean
87+
indentText?: boolean
88+
indentCdata?: boolean
89+
indentAttributes?: boolean
90+
indentInstruction?: boolean
91+
fullTagEmptyElement?: boolean
92+
noQuotesForNativeAttributes?: boolean
93+
doctypeFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
94+
instructionFn?: (
95+
instructionValue: string,
96+
instructionName: string,
97+
currentElementName: string,
98+
currentElementObj: object
99+
) => void;
100+
cdataFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
101+
commentFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
102+
textFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
103+
instructionNameFn?: (
104+
instructionName: string,
105+
instructionValue: string,
106+
currentElementName: string,
107+
currentElementObj: object
108+
) => void;
109+
elementNameFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
110+
attributeNameFn?: (
111+
attributeName: string,
112+
attributeValue: string,
113+
currentElementName: string,
114+
currentElementObj: object
115+
) => void;
116+
attributeValueFn?: (
117+
attributeValue: string,
118+
attributeName: string,
119+
currentElementName: string,
120+
currentElementObj: object
121+
) => void;
122+
attributesFn?: (value: string, currentElementName: string, currentElementObj: object) => void;
123+
fullTagEmptyElementFn?: (currentElementName: string, currentElementObj: object) => void;
124+
}
125+
126+
interface IgnoreOptions {
127+
ignoreDeclaration?: boolean
128+
ignoreInstruction?: boolean
129+
ignoreAttributes?: boolean
130+
ignoreComment?: boolean
131+
ignoreCdata?: boolean
132+
ignoreDoctype?: boolean
133+
ignoreText?: boolean
134+
}
135+
136+
interface ChangingKeyNames {
137+
declarationKey?: string
138+
instructionKey?: string
139+
attributesKey?: string
140+
textKey?: string
141+
cdataKey?: string
142+
doctypeKey?: string
143+
commentKey?: string
144+
parentKey?: string
145+
typeKey?: string
146+
nameKey?: string
147+
elementsKey?: string
148+
}
149+
}

0 commit comments

Comments
 (0)