UNPKG

3.02 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12 return c > 3 && r && Object.defineProperty(target, key, r), r;
13};
14Object.defineProperty(exports, "__esModule", { value: true });
15var context_1 = require("./context/context");
16var LINE_SEPARATOR = '\r\n';
17var XmlFactory = (function () {
18 function XmlFactory() {
19 }
20 XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
21 var _this = this;
22 var props = "";
23 if (xmlElement.properties) {
24 if (xmlElement.properties.prefixedAttributes) {
25 xmlElement.properties.prefixedAttributes.forEach(function (prefixedSet) {
26 Object.keys(prefixedSet.map).forEach(function (key) {
27 props += _this.returnAttributeIfPopulated(prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer);
28 });
29 });
30 }
31 if (xmlElement.properties.rawMap) {
32 Object.keys(xmlElement.properties.rawMap).forEach(function (key) {
33 props += _this.returnAttributeIfPopulated(key, xmlElement.properties.rawMap[key], booleanTransformer);
34 });
35 }
36 }
37 var result = "<" + xmlElement.name + props;
38 if (!xmlElement.children && xmlElement.textNode == null) {
39 return result + "/>" + LINE_SEPARATOR;
40 }
41 if (xmlElement.textNode != null) {
42 return result + ">" + xmlElement.textNode + "</" + xmlElement.name + ">" + LINE_SEPARATOR;
43 }
44 result += ">" + LINE_SEPARATOR;
45 xmlElement.children.forEach(function (it) {
46 result += _this.createXml(it, booleanTransformer);
47 });
48 return result + "</" + xmlElement.name + ">" + LINE_SEPARATOR;
49 };
50 XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
51 if (!value) {
52 return "";
53 }
54 var xmlValue = value;
55 if ((typeof (value) === 'boolean')) {
56 if (booleanTransformer) {
57 xmlValue = booleanTransformer(value);
58 }
59 }
60 xmlValue = '"' + xmlValue + '"';
61 return " " + key + "=" + xmlValue;
62 };
63 XmlFactory = __decorate([
64 context_1.Bean('xmlFactory')
65 ], XmlFactory);
66 return XmlFactory;
67}());
68exports.XmlFactory = XmlFactory;