forked from lantanagroup/FHIR.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmlHelper.js
34 lines (34 loc) · 1.25 KB
/
xmlHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
exports.__esModule = true;
var _ = require("underscore");
var XmlHelper = (function () {
function XmlHelper() {
}
XmlHelper.escapeInvalidCharacters = function (element) {
_.each(element.attributes, function (attribute, index) {
element.attributes[index] = element.attributes[index]
.replace(/&(?!(?:apos|quot|[gl]t|amp);|#)/g, '&');
});
if (element.type === 'text' && element.text) {
element.text = element.text
.replace(/&(?!(?:apos|quot|[gl]t|amp);|#)/g, '&');
}
_.each(element.elements, XmlHelper.escapeInvalidCharacters);
return element;
};
XmlHelper.unescapeInvalidCharacters = function (element) {
_.each(element.attributes, function (attribute, index) {
element.attributes[index] = element.attributes[index]
.replace(/&/g, '&');
});
if (element.type === 'text' && element.text) {
element.text = element.text
.replace(/&/g, '&');
}
_.each(element.elements, XmlHelper.unescapeInvalidCharacters);
return element;
};
return XmlHelper;
}());
exports.XmlHelper = XmlHelper;
//# sourceMappingURL=xmlHelper.js.map