Skip to content

Commit 3f65f68

Browse files
Changes for 4.0.0
1 parent 92f8771 commit 3f65f68

17 files changed

+6737
-1313
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: node_js
22
node_js:
33
- node
4-
- 6
5-
- 5
6-
- 4
4+
- 8
5+
- 10
76
install:
87
- npm install -g gulp
98
- npm install

CHANGES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 4.0.0 ##
2+
3+
* Do not indent multi-line strings
4+
* Use self-closing tags, unless otherwise specified
5+
* Add option to automatically replace invalid characters with U+FFFD
6+
* Add option to suppress certain values from output
7+
* Add support for adding to existing xmlcreate object
8+
* Remove certain unnecessary validation rules
9+
* Bug fixes
10+
* Correct errors in documentation
11+
112
## 3.0.0 ##
213

314
* Bug fixes

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
js2xmlparser
2-
Copyright (C) 2016-2017 Michael Kourlas
2+
Copyright (C) 2016-2019 Michael Kourlas
33

44
## Apache License, version 2.0 ##
55

66
The following components are provided under the [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0):
77

88
xmlcreate
9-
Copyright (C) 2016-2017 Michael Kourlas
9+
Copyright (C) 2016-2019 Michael Kourlas

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ JavaScript objects such as `Date` and `RegExp`, by taking advantage of each
1818
object's `toString` function or, if this function does not exist, the `String`
1919
constructor.
2020

21-
js2xmlparser also has support for the new `Map` and `Set` objects introduced in
21+
js2xmlparser also has support for the `Map` and `Set` objects introduced in
2222
ECMAScript 2015, treating them as JSON-type objects and arrays respectively.
2323
Support for `Map`s is necessary to generate XML with elements in a specific
2424
order, since JSON-type objects do not guarantee insertion order. `Map` keys are
@@ -66,7 +66,7 @@ includes source maps.
6666

6767
## Usage ##
6868

69-
The documentation for the current version is available [here](http://www.kourlas.com/node-js2xmlparser/docs/3.0.0/).
69+
The documentation for the current version is available [here](http://www.kourlas.com/node-js2xmlparser/docs/4.0.0/).
7070

7171
You can also build the documentation using gulp:
7272

@@ -141,7 +141,7 @@ This example produces the following XML:
141141
</person>
142142
```
143143

144-
Additional examples can be found in examples/example.js.
144+
Additional examples can be found in the examples directory.
145145

146146
## Tests ##
147147

examples/example.js renamed to examples/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016 Michael Kourlas
2+
* Copyright (C) 2016-2019 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

examples/typescript.ts

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/**
2+
* Copyright (C) 2016-2019 Michael Kourlas
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/* tslint:disable:no-console object-literal-sort-keys */
18+
19+
import {parse} from "../lib/main";
20+
21+
/**
22+
* This example demonstrates a very simple usage of js2xmlparser.
23+
*/
24+
const example1 = () => {
25+
const obj = {
26+
"firstName": "John",
27+
"lastName": "Smith"
28+
};
29+
console.log(parse("person", obj));
30+
console.log();
31+
};
32+
example1();
33+
34+
/**
35+
* This example demonstrates a more complex usage of j2xmlparser.
36+
*/
37+
const example2 = () => {
38+
const obj = {
39+
"firstName": "John",
40+
"lastName": "Smith",
41+
"dateOfBirth": new Date(1964, 7, 26),
42+
"address": {
43+
"@": {
44+
"type": "home"
45+
},
46+
"streetAddress": "3212 22nd St",
47+
"city": "Chicago",
48+
"state": "Illinois",
49+
"zip": 10000
50+
},
51+
"phone": [
52+
{
53+
"@": {
54+
"type": "home"
55+
},
56+
"#": "123-555-4567"
57+
},
58+
{
59+
"@": {
60+
"type": "cell"
61+
},
62+
"#": "890-555-1234"
63+
},
64+
{
65+
"@": {
66+
"type": "work"
67+
},
68+
"#": "567-555-8901"
69+
}
70+
],
71+
"email": "[email protected]"
72+
};
73+
console.log(parse("person", obj));
74+
console.log();
75+
};
76+
example2();
77+
78+
/**
79+
* This example demonstrates some of js2xmlparser's options.
80+
*/
81+
const example3 = () => {
82+
const options = {
83+
aliasString: "exAlias",
84+
attributeString: "exAttr",
85+
cdataKeys: [
86+
"exCdata",
87+
"exCdata2"
88+
],
89+
declaration: {
90+
include: true,
91+
encoding: "UTF-16",
92+
standalone: "yes",
93+
version: "1.1"
94+
},
95+
dtd: {
96+
include: true,
97+
name: "exName",
98+
sysId: "exSysId",
99+
pubId: "exPubId"
100+
},
101+
format: {
102+
doubleQuotes: true,
103+
indent: "\t",
104+
newline: "\r\n",
105+
pretty: true
106+
},
107+
typeHandlers: {
108+
"[object Number]": (value: any) => {
109+
return value + 17;
110+
}
111+
},
112+
valueString: "exVal",
113+
wrapHandlers: {
114+
"exArr": () => {
115+
return "exArrInner";
116+
}
117+
}
118+
};
119+
120+
const obj = {
121+
"ex1": "ex2",
122+
"exVal_1": 123,
123+
"ex3": ["ex4", "ex5"],
124+
"ex6": {
125+
"exAttr_1": {
126+
"ex7": "ex8",
127+
"ex9": "ex10"
128+
},
129+
"ex11": "ex12",
130+
"ex13": {
131+
"ex14": "ex15"
132+
},
133+
"ex16": [
134+
"ex17",
135+
{
136+
"ex18": "ex19"
137+
}
138+
],
139+
"exArr": [
140+
"ex20",
141+
{
142+
"ex21": "ex22"
143+
}
144+
],
145+
"exAttr_2": {
146+
"ex23": "ex24",
147+
"ex25": "ex26"
148+
}
149+
},
150+
"exVal_2": "ex27",
151+
"ex28": [
152+
"ex29",
153+
"ex30"
154+
],
155+
"ex31": true,
156+
"ex32": undefined,
157+
"ex33": null,
158+
"ex34": 3.4,
159+
"ex35": () => {
160+
return "ex36";
161+
},
162+
"ex37": "i<j&",
163+
"exCdata": "i<j&",
164+
"exCdata2": "ddd",
165+
"ex38": {
166+
"exAlias": "ex39",
167+
"ex40": "ex41"
168+
},
169+
"ex42": ["ex43", "ex44", "ex45", ["ex46", "ex47"],
170+
new Set(["ex48", "ex49"])],
171+
"ex50": new Map([
172+
["ex51", "ex52"],
173+
["exVal_1", "ex53"],
174+
["ex54", "ex55"],
175+
["exAttr_1",
176+
{
177+
"ex56": "ex57",
178+
"ex58": "ex59"
179+
}
180+
] as any
181+
])
182+
};
183+
console.log(parse("ex0", obj, options));
184+
console.log();
185+
};
186+
example3();

0 commit comments

Comments
 (0)