xslt-processor 2.3.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -3
- package/dom/util.d.ts +1 -1
- package/dom/util.js.map +1 -1
- package/package.json +10 -10
- package/umd/dom/util.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-pi.d.ts +1 -1
- package/umd/xpath/tokens.d.ts +3 -3
- package/umd/xpath/xpath.d.ts +12 -8
- package/umd/xslt/xslt.d.ts +37 -12
- package/umd/xslt-processor.js +2 -2
- package/umd/xslt-processor.js.map +1 -1
- package/xpath/match-resolver.js +1 -1
- package/xpath/node-tests/node-test-pi.d.ts +1 -1
- package/xpath/node-tests/node-test-pi.js +2 -2
- package/xpath/node-tests/node-test-pi.js.map +1 -1
- package/xpath/tokens.d.ts +3 -3
- package/xpath/tokens.js +4 -4
- package/xpath/tokens.js.map +1 -1
- package/xpath/xpath.d.ts +12 -8
- package/xpath/xpath.js +33 -31
- package/xpath/xpath.js.map +1 -1
- package/xslt/xslt.d.ts +37 -12
- package/xslt/xslt.js +763 -447
- package/xslt/xslt.js.map +1 -1
package/xslt/xslt.js
CHANGED
|
@@ -8,8 +8,68 @@
|
|
|
8
8
|
// remaining XSLT features.
|
|
9
9
|
//
|
|
10
10
|
// Original author: Steffen Meschkat <mesch@google.com>
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
35
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
44
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
45
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
46
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
47
|
+
function step(op) {
|
|
48
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
49
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
50
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
51
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
52
|
+
switch (op[0]) {
|
|
53
|
+
case 0: case 1: t = op; break;
|
|
54
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
55
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
56
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
57
|
+
default:
|
|
58
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
59
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
60
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
61
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
62
|
+
if (t[2]) _.ops.pop();
|
|
63
|
+
_.trys.pop(); continue;
|
|
64
|
+
}
|
|
65
|
+
op = body.call(thisArg, _);
|
|
66
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
67
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
11
70
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
71
|
exports.Xslt = void 0;
|
|
72
|
+
var node_fetch_1 = __importStar(require("node-fetch"));
|
|
13
73
|
var dom_1 = require("../dom");
|
|
14
74
|
var xpath_1 = require("../xpath");
|
|
15
75
|
var constants_1 = require("../constants");
|
|
@@ -48,6 +108,7 @@ var Xslt = /** @class */ (function () {
|
|
|
48
108
|
parameters: []
|
|
49
109
|
}; }
|
|
50
110
|
this.xPath = new xpath_1.XPath();
|
|
111
|
+
this.xmlParser = new dom_1.XmlParser();
|
|
51
112
|
this.matchResolver = new match_resolver_1.MatchResolver();
|
|
52
113
|
this.options = {
|
|
53
114
|
cData: options.cData === true,
|
|
@@ -77,23 +138,33 @@ var Xslt = /** @class */ (function () {
|
|
|
77
138
|
* @returns the processed document, as XML text in a string.
|
|
78
139
|
*/
|
|
79
140
|
Xslt.prototype.xsltProcess = function (xmlDoc, stylesheet) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
var outputDocument, expressionContext, _i, _a, parameter, transformedOutputXml;
|
|
143
|
+
return __generator(this, function (_b) {
|
|
144
|
+
switch (_b.label) {
|
|
145
|
+
case 0:
|
|
146
|
+
outputDocument = new dom_1.XDocument();
|
|
147
|
+
this.outputDocument = outputDocument;
|
|
148
|
+
expressionContext = new xpath_1.ExprContext([xmlDoc], [outputDocument]);
|
|
149
|
+
if (this.options.parameters.length > 0) {
|
|
150
|
+
for (_i = 0, _a = this.options.parameters; _i < _a.length; _i++) {
|
|
151
|
+
parameter = _a[_i];
|
|
152
|
+
expressionContext.setVariable(parameter.name, new values_1.StringValue(parameter.value));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return [4 /*yield*/, this.xsltProcessContext(expressionContext, stylesheet, this.outputDocument)];
|
|
156
|
+
case 1:
|
|
157
|
+
_b.sent();
|
|
158
|
+
transformedOutputXml = (0, dom_1.xmlTransformedText)(outputDocument, {
|
|
159
|
+
cData: this.options.cData,
|
|
160
|
+
escape: this.options.escape,
|
|
161
|
+
selfClosingTags: this.options.selfClosingTags,
|
|
162
|
+
outputMethod: this.outputMethod
|
|
163
|
+
});
|
|
164
|
+
return [2 /*return*/, transformedOutputXml];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
95
167
|
});
|
|
96
|
-
return transformedOutputXml;
|
|
97
168
|
};
|
|
98
169
|
/**
|
|
99
170
|
* The main entry point of the XSL-T processor, as explained on the top of the file.
|
|
@@ -102,302 +173,409 @@ var Xslt = /** @class */ (function () {
|
|
|
102
173
|
* @param output If set, the output where the transformation should occur.
|
|
103
174
|
*/
|
|
104
175
|
Xslt.prototype.xsltProcessContext = function (context, template, output) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
var name_1, top_1, nameExpr, node, select, value, nodes, paramContext, commentData, commentNode, test_1, match, text, _a, i, childNode, destinationCopyNode, destinationNode, i, node_1, decimalSeparator, groupingSeparator, infinity, minusSign, naN, percent, perMille, zeroDigit, digit, patternSeparator, clonedContext, templateContext, disableOutputEscaping, destinationTextNode, attribute;
|
|
178
|
+
return __generator(this, function (_b) {
|
|
179
|
+
switch (_b.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
if (!!this.isXsltElement(template)) return [3 /*break*/, 2];
|
|
182
|
+
return [4 /*yield*/, this.xsltPassThrough(context, template, output)];
|
|
183
|
+
case 1:
|
|
184
|
+
_b.sent();
|
|
185
|
+
return [3 /*break*/, 59];
|
|
186
|
+
case 2:
|
|
187
|
+
nameExpr = void 0, node = void 0, select = void 0, value = void 0, nodes = void 0, paramContext = void 0, commentData = void 0, commentNode = void 0, match = void 0, text = void 0;
|
|
188
|
+
_a = template.localName;
|
|
189
|
+
switch (_a) {
|
|
190
|
+
case 'apply-imports': return [3 /*break*/, 3];
|
|
191
|
+
case 'apply-templates': return [3 /*break*/, 4];
|
|
192
|
+
case 'attribute': return [3 /*break*/, 6];
|
|
193
|
+
case 'attribute-set': return [3 /*break*/, 8];
|
|
194
|
+
case 'call-template': return [3 /*break*/, 9];
|
|
195
|
+
case 'choose': return [3 /*break*/, 15];
|
|
196
|
+
case 'comment': return [3 /*break*/, 17];
|
|
197
|
+
case 'copy': return [3 /*break*/, 19];
|
|
198
|
+
case 'copy-of': return [3 /*break*/, 22];
|
|
199
|
+
case 'decimal-format': return [3 /*break*/, 23];
|
|
200
|
+
case 'element': return [3 /*break*/, 24];
|
|
201
|
+
case 'fallback': return [3 /*break*/, 26];
|
|
202
|
+
case 'for-each': return [3 /*break*/, 27];
|
|
203
|
+
case 'if': return [3 /*break*/, 29];
|
|
204
|
+
case 'import': return [3 /*break*/, 32];
|
|
205
|
+
case 'include': return [3 /*break*/, 33];
|
|
206
|
+
case 'key': return [3 /*break*/, 35];
|
|
207
|
+
case 'message': return [3 /*break*/, 36];
|
|
208
|
+
case 'namespace-alias': return [3 /*break*/, 37];
|
|
209
|
+
case 'number': return [3 /*break*/, 38];
|
|
210
|
+
case 'otherwise': return [3 /*break*/, 39];
|
|
211
|
+
case 'output': return [3 /*break*/, 40];
|
|
212
|
+
case 'param': return [3 /*break*/, 41];
|
|
213
|
+
case 'preserve-space': return [3 /*break*/, 43];
|
|
214
|
+
case 'processing-instruction': return [3 /*break*/, 44];
|
|
215
|
+
case 'sort': return [3 /*break*/, 45];
|
|
216
|
+
case 'strip-space': return [3 /*break*/, 46];
|
|
217
|
+
case 'stylesheet': return [3 /*break*/, 47];
|
|
218
|
+
case 'transform': return [3 /*break*/, 47];
|
|
219
|
+
case 'template': return [3 /*break*/, 49];
|
|
220
|
+
case 'text': return [3 /*break*/, 52];
|
|
221
|
+
case 'value-of': return [3 /*break*/, 53];
|
|
222
|
+
case 'variable': return [3 /*break*/, 54];
|
|
223
|
+
case 'when': return [3 /*break*/, 56];
|
|
224
|
+
case 'with-param': return [3 /*break*/, 57];
|
|
137
225
|
}
|
|
138
|
-
|
|
139
|
-
|
|
226
|
+
return [3 /*break*/, 58];
|
|
227
|
+
case 3: throw new Error("not implemented: ".concat(template.localName));
|
|
228
|
+
case 4: return [4 /*yield*/, this.xsltApplyTemplates(context, template, output)];
|
|
229
|
+
case 5:
|
|
230
|
+
_b.sent();
|
|
231
|
+
return [3 /*break*/, 59];
|
|
232
|
+
case 6: return [4 /*yield*/, this.xsltAttribute(context, template, output)];
|
|
233
|
+
case 7:
|
|
234
|
+
_b.sent();
|
|
235
|
+
return [3 /*break*/, 59];
|
|
236
|
+
case 8: throw new Error("not implemented: ".concat(template.localName));
|
|
237
|
+
case 9:
|
|
238
|
+
name_1 = (0, dom_1.xmlGetAttribute)(template, 'name');
|
|
239
|
+
top_1 = template.ownerDocument.documentElement;
|
|
240
|
+
paramContext = context.clone();
|
|
241
|
+
return [4 /*yield*/, this.xsltWithParam(paramContext, template)];
|
|
242
|
+
case 10:
|
|
243
|
+
_b.sent();
|
|
244
|
+
i = 0;
|
|
245
|
+
_b.label = 11;
|
|
246
|
+
case 11:
|
|
247
|
+
if (!(i < top_1.childNodes.length)) return [3 /*break*/, 14];
|
|
248
|
+
childNode = top_1.childNodes[i];
|
|
249
|
+
if (!(childNode.nodeType === constants_1.DOM_ELEMENT_NODE &&
|
|
250
|
+
this.isXsltElement(childNode, 'template') &&
|
|
251
|
+
(0, dom_1.domGetAttributeValue)(childNode, 'name') == name_1)) return [3 /*break*/, 13];
|
|
252
|
+
return [4 /*yield*/, this.xsltChildNodes(paramContext, childNode, output)];
|
|
253
|
+
case 12:
|
|
254
|
+
_b.sent();
|
|
255
|
+
return [3 /*break*/, 14];
|
|
256
|
+
case 13:
|
|
257
|
+
++i;
|
|
258
|
+
return [3 /*break*/, 11];
|
|
259
|
+
case 14: return [3 /*break*/, 59];
|
|
260
|
+
case 15: return [4 /*yield*/, this.xsltChoose(context, template, output)];
|
|
261
|
+
case 16:
|
|
262
|
+
_b.sent();
|
|
263
|
+
return [3 /*break*/, 59];
|
|
264
|
+
case 17:
|
|
265
|
+
node = (0, dom_1.domCreateDocumentFragment)(this.outputDocument);
|
|
266
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, node)];
|
|
267
|
+
case 18:
|
|
268
|
+
_b.sent();
|
|
269
|
+
commentData = (0, dom_1.xmlValue)(node);
|
|
270
|
+
commentNode = (0, dom_1.domCreateComment)(this.outputDocument, commentData);
|
|
271
|
+
output.appendChild(commentNode);
|
|
272
|
+
return [3 /*break*/, 59];
|
|
273
|
+
case 19:
|
|
274
|
+
destinationCopyNode = output || context.outputNodeList[context.outputPosition];
|
|
275
|
+
node = this.xsltCopy(destinationCopyNode, context.nodeList[context.position]);
|
|
276
|
+
if (!node) return [3 /*break*/, 21];
|
|
277
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, node)];
|
|
278
|
+
case 20:
|
|
279
|
+
_b.sent();
|
|
280
|
+
_b.label = 21;
|
|
281
|
+
case 21: return [3 /*break*/, 59];
|
|
282
|
+
case 22:
|
|
283
|
+
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
284
|
+
value = this.xPath.xPathEval(select, context);
|
|
285
|
+
destinationNode = context.outputNodeList[context.outputPosition] || output;
|
|
286
|
+
if (value.type === 'node-set') {
|
|
287
|
+
nodes = value.nodeSetValue();
|
|
288
|
+
for (i = 0; i < nodes.length; ++i) {
|
|
289
|
+
this.xsltCopyOf(destinationNode, nodes[i]);
|
|
290
|
+
}
|
|
140
291
|
}
|
|
141
|
-
|
|
142
|
-
|
|
292
|
+
else {
|
|
293
|
+
node_1 = (0, dom_1.domCreateTextNode)(this.outputDocument, value.stringValue());
|
|
294
|
+
(0, dom_1.domAppendChild)(destinationNode, node_1);
|
|
143
295
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
296
|
+
return [3 /*break*/, 59];
|
|
297
|
+
case 23:
|
|
298
|
+
name_1 = (0, dom_1.xmlGetAttribute)(template, 'name');
|
|
299
|
+
decimalSeparator = (0, dom_1.xmlGetAttribute)(template, 'decimal-separator');
|
|
300
|
+
groupingSeparator = (0, dom_1.xmlGetAttribute)(template, 'grouping-separator');
|
|
301
|
+
infinity = (0, dom_1.xmlGetAttribute)(template, 'infinity');
|
|
302
|
+
minusSign = (0, dom_1.xmlGetAttribute)(template, 'minus-sign');
|
|
303
|
+
naN = (0, dom_1.xmlGetAttribute)(template, 'NaN');
|
|
304
|
+
percent = (0, dom_1.xmlGetAttribute)(template, 'percent');
|
|
305
|
+
perMille = (0, dom_1.xmlGetAttribute)(template, 'per-mille');
|
|
306
|
+
zeroDigit = (0, dom_1.xmlGetAttribute)(template, 'zero-digit');
|
|
307
|
+
digit = (0, dom_1.xmlGetAttribute)(template, 'digit');
|
|
308
|
+
patternSeparator = (0, dom_1.xmlGetAttribute)(template, 'pattern-separator');
|
|
309
|
+
this.decimalFormatSettings = {
|
|
310
|
+
name: name_1 || this.decimalFormatSettings.name,
|
|
311
|
+
decimalSeparator: decimalSeparator || this.decimalFormatSettings.decimalSeparator,
|
|
312
|
+
groupingSeparator: groupingSeparator || this.decimalFormatSettings.groupingSeparator,
|
|
313
|
+
infinity: infinity || this.decimalFormatSettings.infinity,
|
|
314
|
+
minusSign: minusSign || this.decimalFormatSettings.minusSign,
|
|
315
|
+
naN: naN || this.decimalFormatSettings.naN,
|
|
316
|
+
percent: percent || this.decimalFormatSettings.percent,
|
|
317
|
+
perMille: perMille || this.decimalFormatSettings.perMille,
|
|
318
|
+
zeroDigit: zeroDigit || this.decimalFormatSettings.zeroDigit,
|
|
319
|
+
digit: digit || this.decimalFormatSettings.digit,
|
|
320
|
+
patternSeparator: patternSeparator || this.decimalFormatSettings.patternSeparator
|
|
321
|
+
};
|
|
322
|
+
context.decimalFormatSettings = this.decimalFormatSettings;
|
|
323
|
+
return [3 /*break*/, 59];
|
|
324
|
+
case 24:
|
|
325
|
+
nameExpr = (0, dom_1.xmlGetAttribute)(template, 'name');
|
|
326
|
+
name_1 = this.xsltAttributeValue(nameExpr, context);
|
|
327
|
+
node = (0, dom_1.domCreateElement)(this.outputDocument, name_1);
|
|
328
|
+
node.transformedNodeName = name_1;
|
|
329
|
+
(0, dom_1.domAppendTransformedChild)(context.outputNodeList[context.outputPosition], node);
|
|
330
|
+
clonedContext = context.clone(undefined, [node], undefined, 0);
|
|
331
|
+
return [4 /*yield*/, this.xsltChildNodes(clonedContext, template, node)];
|
|
332
|
+
case 25:
|
|
333
|
+
_b.sent();
|
|
334
|
+
return [3 /*break*/, 59];
|
|
335
|
+
case 26: throw new Error("not implemented: ".concat(template.localName));
|
|
336
|
+
case 27: return [4 /*yield*/, this.xsltForEach(context, template, output)];
|
|
337
|
+
case 28:
|
|
338
|
+
_b.sent();
|
|
339
|
+
return [3 /*break*/, 59];
|
|
340
|
+
case 29:
|
|
341
|
+
test_1 = (0, dom_1.xmlGetAttribute)(template, 'test');
|
|
342
|
+
if (!this.xPath.xPathEval(test_1, context).booleanValue()) return [3 /*break*/, 31];
|
|
343
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, output)];
|
|
344
|
+
case 30:
|
|
345
|
+
_b.sent();
|
|
346
|
+
_b.label = 31;
|
|
347
|
+
case 31: return [3 /*break*/, 59];
|
|
348
|
+
case 32: throw new Error("not implemented: ".concat(template.localName));
|
|
349
|
+
case 33: return [4 /*yield*/, this.xsltInclude(context, template, output)];
|
|
350
|
+
case 34:
|
|
351
|
+
_b.sent();
|
|
352
|
+
return [3 /*break*/, 59];
|
|
353
|
+
case 35: throw new Error("not implemented: ".concat(template.localName));
|
|
354
|
+
case 36: throw new Error("not implemented: ".concat(template.localName));
|
|
355
|
+
case 37: throw new Error("not implemented: ".concat(template.localName));
|
|
356
|
+
case 38: throw new Error("not implemented: ".concat(template.localName));
|
|
357
|
+
case 39: throw "error if here: ".concat(template.localName);
|
|
358
|
+
case 40:
|
|
359
|
+
this.outputMethod = (0, dom_1.xmlGetAttribute)(template, 'method');
|
|
360
|
+
this.outputOmitXmlDeclaration = (0, dom_1.xmlGetAttribute)(template, 'omit-xml-declaration');
|
|
361
|
+
return [3 /*break*/, 59];
|
|
362
|
+
case 41: return [4 /*yield*/, this.xsltVariable(context, template, false)];
|
|
363
|
+
case 42:
|
|
364
|
+
_b.sent();
|
|
365
|
+
return [3 /*break*/, 59];
|
|
366
|
+
case 43: throw new Error("not implemented: ".concat(template.localName));
|
|
367
|
+
case 44: throw new Error("not implemented: ".concat(template.localName));
|
|
368
|
+
case 45:
|
|
369
|
+
this.xsltSort(context, template);
|
|
370
|
+
return [3 /*break*/, 59];
|
|
371
|
+
case 46: throw new Error("not implemented: ".concat(template.localName));
|
|
372
|
+
case 47: return [4 /*yield*/, this.xsltTransformOrStylesheet(template, context, output)];
|
|
373
|
+
case 48:
|
|
374
|
+
_b.sent();
|
|
375
|
+
return [3 /*break*/, 59];
|
|
376
|
+
case 49:
|
|
377
|
+
// If `<xsl:template>` is executed outside `<xsl:apply-templates>`,
|
|
378
|
+
// only one match is accepted per level (or per context here).
|
|
379
|
+
if (!context.inApplyTemplates && context.baseTemplateMatched) {
|
|
380
|
+
return [3 /*break*/, 59];
|
|
167
381
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
var sourceNode = context.nodeList[context.position];
|
|
181
|
-
var parentSourceNode = sourceNode.parentNode;
|
|
182
|
-
var outputNode = sourceNode.outputNode;
|
|
183
|
-
// At this point, the output node should exist.
|
|
184
|
-
// If not, a new node is created.
|
|
185
|
-
if (outputNode === null || outputNode === undefined) {
|
|
186
|
-
outputNode = new dom_1.XNode(sourceNode.nodeType, sourceNode.nodeName, sourceNode.nodeValue, context.outputNodeList[context.outputPosition], sourceNode.namespaceUri);
|
|
187
|
-
sourceNode.outputNode = outputNode;
|
|
382
|
+
match = (0, dom_1.xmlGetAttribute)(template, 'match');
|
|
383
|
+
if (!match)
|
|
384
|
+
return [3 /*break*/, 59];
|
|
385
|
+
// XPath doesn't have an axis to select "self and siblings", and
|
|
386
|
+
// the default axis is "child", so to select the correct children
|
|
387
|
+
// in relative path, we force a 'self-and-siblings' axis.
|
|
388
|
+
nodes = this.xsltMatch(match, context, 'self-and-siblings');
|
|
389
|
+
if (!(nodes.length > 0)) return [3 /*break*/, 51];
|
|
390
|
+
if (!context.inApplyTemplates) {
|
|
391
|
+
context.baseTemplateMatched = true;
|
|
188
392
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
393
|
+
templateContext = context.clone(nodes, undefined, 0);
|
|
394
|
+
return [4 /*yield*/, this.xsltChildNodes(templateContext, template, output)];
|
|
395
|
+
case 50:
|
|
396
|
+
_b.sent();
|
|
397
|
+
_b.label = 51;
|
|
398
|
+
case 51: return [3 /*break*/, 59];
|
|
399
|
+
case 52:
|
|
400
|
+
text = (0, dom_1.xmlValue)(template);
|
|
401
|
+
node = (0, dom_1.domCreateTransformedTextNode)(this.outputDocument, text);
|
|
402
|
+
disableOutputEscaping = template.childNodes.filter(function (a) { return a.nodeType === constants_1.DOM_ATTRIBUTE_NODE && a.nodeName === 'disable-output-escaping'; });
|
|
403
|
+
if (disableOutputEscaping.length > 0 && disableOutputEscaping[0].nodeValue === 'yes') {
|
|
404
|
+
node.escape = false;
|
|
201
405
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
406
|
+
destinationTextNode = output || context.outputNodeList[context.outputPosition];
|
|
407
|
+
destinationTextNode.appendTransformedChild(node);
|
|
408
|
+
return [3 /*break*/, 59];
|
|
409
|
+
case 53:
|
|
410
|
+
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
411
|
+
attribute = this.xPath.xPathEval(select, context);
|
|
412
|
+
value = attribute.stringValue();
|
|
413
|
+
node = (0, dom_1.domCreateTransformedTextNode)(this.outputDocument, value);
|
|
414
|
+
node.siblingPosition = context.nodeList[context.position].siblingPosition;
|
|
415
|
+
if (output.nodeType === constants_1.DOM_DOCUMENT_FRAGMENT_NODE) {
|
|
416
|
+
output.appendTransformedChild(node);
|
|
210
417
|
}
|
|
211
418
|
else {
|
|
212
|
-
|
|
419
|
+
context.outputNodeList[context.outputPosition].appendTransformedChild(node);
|
|
213
420
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
421
|
+
return [3 /*break*/, 59];
|
|
422
|
+
case 54: return [4 /*yield*/, this.xsltVariable(context, template, true)];
|
|
423
|
+
case 55:
|
|
424
|
+
_b.sent();
|
|
425
|
+
return [3 /*break*/, 59];
|
|
426
|
+
case 56: throw new Error("error if here: ".concat(template.localName));
|
|
427
|
+
case 57: throw new Error("error if here: ".concat(template.localName));
|
|
428
|
+
case 58: throw new Error("error if here: ".concat(template.localName));
|
|
429
|
+
case 59: return [2 /*return*/];
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Implements `xsl:apply-templates`.
|
|
436
|
+
* @param context The Expression Context.
|
|
437
|
+
* @param template The template.
|
|
438
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
439
|
+
* @protected
|
|
440
|
+
*/
|
|
441
|
+
Xslt.prototype.xsltApplyTemplates = function (context, template, output) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
443
|
+
var getAllTemplates, select, nodes, mode, top, templates, modifiedContext, i, j, textNodeContext, clonedContext;
|
|
444
|
+
var _this = this;
|
|
445
|
+
return __generator(this, function (_a) {
|
|
446
|
+
switch (_a.label) {
|
|
447
|
+
case 0:
|
|
448
|
+
getAllTemplates = function (top, template, mode) {
|
|
449
|
+
var templates = [];
|
|
450
|
+
for (var _i = 0, _a = top.childNodes.filter(function (c) { return c.nodeType == constants_1.DOM_ELEMENT_NODE && _this.isXsltElement(c, 'template'); }); _i < _a.length; _i++) {
|
|
451
|
+
var element = _a[_i];
|
|
452
|
+
// TODO: Remember why this logic was here.
|
|
453
|
+
// In the past the idea was to avoid executing the same matcher repeatedly,
|
|
454
|
+
// but this proved to be a *terrible* idea some time later.
|
|
455
|
+
// Will keep this code for a few more versions, then remove it.
|
|
456
|
+
/* const templateAncestor = template.getAncestorByLocalName('template');
|
|
457
|
+
if (templateAncestor === undefined) {
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (templateAncestor.id === element.id) {
|
|
462
|
+
continue;
|
|
463
|
+
} */
|
|
464
|
+
if (!mode || element.getAttributeValue('mode') === mode) {
|
|
465
|
+
templates.push(element);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return templates;
|
|
469
|
+
};
|
|
470
|
+
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
471
|
+
nodes = [];
|
|
472
|
+
if (select) {
|
|
473
|
+
nodes = this.xPath.xPathEval(select, context).nodeSetValue();
|
|
230
474
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
case 'choose':
|
|
234
|
-
this.xsltChoose(context, template, output);
|
|
235
|
-
break;
|
|
236
|
-
case 'comment':
|
|
237
|
-
node = (0, dom_1.domCreateDocumentFragment)(this.outputDocument);
|
|
238
|
-
this.xsltChildNodes(context, template, node);
|
|
239
|
-
commentData = (0, dom_1.xmlValue)(node);
|
|
240
|
-
commentNode = (0, dom_1.domCreateComment)(this.outputDocument, commentData);
|
|
241
|
-
output.appendChild(commentNode);
|
|
242
|
-
break;
|
|
243
|
-
case 'copy':
|
|
244
|
-
var destinationCopyNode = output || context.outputNodeList[context.outputPosition];
|
|
245
|
-
node = this.xsltCopy(destinationCopyNode, context.nodeList[context.position]);
|
|
246
|
-
if (node) {
|
|
247
|
-
this.xsltChildNodes(context, template, node);
|
|
248
|
-
}
|
|
249
|
-
break;
|
|
250
|
-
case 'copy-of':
|
|
251
|
-
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
252
|
-
value = this.xPath.xPathEval(select, context);
|
|
253
|
-
var destinationNode = context.outputNodeList[context.outputPosition] || output;
|
|
254
|
-
if (value.type === 'node-set') {
|
|
255
|
-
nodes = value.nodeSetValue();
|
|
256
|
-
for (var i = 0; i < nodes.length; ++i) {
|
|
257
|
-
this.xsltCopyOf(destinationNode, nodes[i]);
|
|
475
|
+
else {
|
|
476
|
+
nodes = context.nodeList[context.position].childNodes;
|
|
258
477
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
320
|
-
case 'namespace-alias':
|
|
321
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
322
|
-
case 'number':
|
|
323
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
324
|
-
case 'otherwise':
|
|
325
|
-
throw "error if here: ".concat(template.localName);
|
|
326
|
-
case 'output':
|
|
327
|
-
this.outputMethod = (0, dom_1.xmlGetAttribute)(template, 'method');
|
|
328
|
-
this.outputOmitXmlDeclaration = (0, dom_1.xmlGetAttribute)(template, 'omit-xml-declaration');
|
|
329
|
-
break;
|
|
330
|
-
case 'param':
|
|
331
|
-
this.xsltVariable(context, template, false);
|
|
332
|
-
break;
|
|
333
|
-
case 'preserve-space':
|
|
334
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
335
|
-
case 'processing-instruction':
|
|
336
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
337
|
-
case 'sort':
|
|
338
|
-
this.xsltSort(context, template);
|
|
339
|
-
break;
|
|
340
|
-
case 'strip-space':
|
|
341
|
-
throw new Error("not implemented: ".concat(template.localName));
|
|
342
|
-
case 'stylesheet':
|
|
343
|
-
case 'transform':
|
|
344
|
-
this.xsltTransformOrStylesheet(template, context, output);
|
|
345
|
-
break;
|
|
346
|
-
case 'template':
|
|
347
|
-
// If `<xsl:template>` is executed outside `<xsl:apply-templates>`,
|
|
348
|
-
// only one match is accepted per level (or per context here).
|
|
349
|
-
if (!context.inApplyTemplates && context.baseTemplateMatched) {
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
match = (0, dom_1.xmlGetAttribute)(template, 'match');
|
|
353
|
-
if (!match)
|
|
354
|
-
break;
|
|
355
|
-
// XPath doesn't have an axis to select "self and siblings", and
|
|
356
|
-
// the default axis is "child", so to select the correct children
|
|
357
|
-
// in relative path, we force a 'self-and-siblings' axis.
|
|
358
|
-
nodes = this.xsltMatch(match, context, 'self-and-siblings');
|
|
359
|
-
if (nodes.length > 0) {
|
|
360
|
-
if (!context.inApplyTemplates) {
|
|
361
|
-
context.baseTemplateMatched = true;
|
|
478
|
+
mode = (0, dom_1.xmlGetAttribute)(template, 'mode');
|
|
479
|
+
top = template.ownerDocument.documentElement;
|
|
480
|
+
templates = getAllTemplates(top, template, mode);
|
|
481
|
+
modifiedContext = context.clone(nodes);
|
|
482
|
+
i = 0;
|
|
483
|
+
_a.label = 1;
|
|
484
|
+
case 1:
|
|
485
|
+
if (!(i < templates.length)) return [3 /*break*/, 7];
|
|
486
|
+
j = 0;
|
|
487
|
+
_a.label = 2;
|
|
488
|
+
case 2:
|
|
489
|
+
if (!(j < modifiedContext.contextSize())) return [3 /*break*/, 6];
|
|
490
|
+
if (!(modifiedContext.nodeList[j].nodeType === constants_1.DOM_TEXT_NODE)) return [3 /*break*/, 3];
|
|
491
|
+
textNodeContext = context.clone([modifiedContext.nodeList[j]], undefined, 0, undefined);
|
|
492
|
+
// TODO: verify if it is okay to pass the own text node as template.
|
|
493
|
+
this.commonLogicTextNode(textNodeContext, modifiedContext.nodeList[j], output);
|
|
494
|
+
return [3 /*break*/, 5];
|
|
495
|
+
case 3:
|
|
496
|
+
clonedContext = modifiedContext.clone([modifiedContext.nodeList[j]], undefined, 0, undefined);
|
|
497
|
+
clonedContext.inApplyTemplates = true;
|
|
498
|
+
// The output depth should be restarted, since
|
|
499
|
+
// another template is being applied from this point.
|
|
500
|
+
clonedContext.outputDepth = 0;
|
|
501
|
+
return [4 /*yield*/, this.xsltProcessContext(clonedContext, templates[i], output)];
|
|
502
|
+
case 4:
|
|
503
|
+
_a.sent();
|
|
504
|
+
_a.label = 5;
|
|
505
|
+
case 5:
|
|
506
|
+
++j;
|
|
507
|
+
return [3 /*break*/, 2];
|
|
508
|
+
case 6:
|
|
509
|
+
++i;
|
|
510
|
+
return [3 /*break*/, 1];
|
|
511
|
+
case 7: return [2 /*return*/];
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Implements `xsl:attribute`.
|
|
518
|
+
* @param context The Expression Context.
|
|
519
|
+
* @param template The template.
|
|
520
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
521
|
+
* @protected
|
|
522
|
+
*/
|
|
523
|
+
Xslt.prototype.xsltAttribute = function (context, template, output) {
|
|
524
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
525
|
+
var nameExpr, name, documentFragment, value, sourceNode, parentSourceNode, outputNode, sourceRootNode, newRootNode;
|
|
526
|
+
return __generator(this, function (_a) {
|
|
527
|
+
switch (_a.label) {
|
|
528
|
+
case 0:
|
|
529
|
+
nameExpr = (0, dom_1.xmlGetAttribute)(template, 'name');
|
|
530
|
+
name = this.xsltAttributeValue(nameExpr, context);
|
|
531
|
+
documentFragment = (0, dom_1.domCreateDocumentFragment)(this.outputDocument);
|
|
532
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, documentFragment)];
|
|
533
|
+
case 1:
|
|
534
|
+
_a.sent();
|
|
535
|
+
value = (0, dom_1.xmlValue2)(documentFragment);
|
|
536
|
+
if (output.nodeType === constants_1.DOM_DOCUMENT_FRAGMENT_NODE) {
|
|
537
|
+
(0, dom_1.domSetTransformedAttribute)(output, name, value);
|
|
362
538
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
539
|
+
else {
|
|
540
|
+
sourceNode = context.nodeList[context.position];
|
|
541
|
+
parentSourceNode = sourceNode.parentNode;
|
|
542
|
+
outputNode = sourceNode.outputNode;
|
|
543
|
+
// At this point, the output node should exist.
|
|
544
|
+
// If not, a new node is created.
|
|
545
|
+
if (outputNode === null || outputNode === undefined) {
|
|
546
|
+
outputNode = new dom_1.XNode(sourceNode.nodeType, sourceNode.nodeName, sourceNode.nodeValue, context.outputNodeList[context.outputPosition], sourceNode.namespaceUri);
|
|
547
|
+
sourceNode.outputNode = outputNode;
|
|
548
|
+
}
|
|
549
|
+
// Corner case:
|
|
550
|
+
// It can happen here that we don't have the root node set.
|
|
551
|
+
// In this case we need to append a copy of the root
|
|
552
|
+
// source node to receive the attribute.
|
|
553
|
+
if (outputNode.localName === '#document') {
|
|
554
|
+
sourceRootNode = context.root.childNodes[0];
|
|
555
|
+
newRootNode = (0, dom_1.domCreateElement)(this.outputDocument, sourceRootNode.nodeName);
|
|
556
|
+
newRootNode.transformedNodeName = sourceRootNode.nodeName;
|
|
557
|
+
newRootNode.transformedLocalName = sourceRootNode.localName;
|
|
558
|
+
(0, dom_1.domAppendTransformedChild)(outputNode, newRootNode);
|
|
559
|
+
outputNode = newRootNode;
|
|
560
|
+
parentSourceNode = newRootNode;
|
|
561
|
+
}
|
|
562
|
+
// If the parent transformation is something like `xsl:element`, we should
|
|
563
|
+
// add a copy of the attribute to this element.
|
|
564
|
+
(0, dom_1.domSetTransformedAttribute)(output, name, value);
|
|
565
|
+
// Some operations start by the tag attributes, and not by the tag itself.
|
|
566
|
+
// When this is the case, the output node is not set yet, so
|
|
567
|
+
// we add the transformed attributes into the original tag.
|
|
568
|
+
if (parentSourceNode && parentSourceNode.outputNode) {
|
|
569
|
+
(0, dom_1.domSetTransformedAttribute)(parentSourceNode.outputNode, name, value);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
(0, dom_1.domSetTransformedAttribute)(parentSourceNode, name, value);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return [2 /*return*/];
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
});
|
|
401
579
|
};
|
|
402
580
|
/**
|
|
403
581
|
* Implements `xsl:choose`, its child nodes `xsl:when`, and
|
|
@@ -407,25 +585,42 @@ var Xslt = /** @class */ (function () {
|
|
|
407
585
|
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
408
586
|
*/
|
|
409
587
|
Xslt.prototype.xsltChoose = function (context, template, output) {
|
|
410
|
-
|
|
411
|
-
var childNode
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
588
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
589
|
+
var _i, _a, childNode, test_2, outputNode, outputNode;
|
|
590
|
+
return __generator(this, function (_b) {
|
|
591
|
+
switch (_b.label) {
|
|
592
|
+
case 0:
|
|
593
|
+
_i = 0, _a = template.childNodes;
|
|
594
|
+
_b.label = 1;
|
|
595
|
+
case 1:
|
|
596
|
+
if (!(_i < _a.length)) return [3 /*break*/, 7];
|
|
597
|
+
childNode = _a[_i];
|
|
598
|
+
if (childNode.nodeType !== constants_1.DOM_ELEMENT_NODE) {
|
|
599
|
+
return [3 /*break*/, 6];
|
|
600
|
+
}
|
|
601
|
+
if (!this.isXsltElement(childNode, 'when')) return [3 /*break*/, 4];
|
|
602
|
+
test_2 = (0, dom_1.xmlGetAttribute)(childNode, 'test');
|
|
603
|
+
if (!this.xPath.xPathEval(test_2, context).booleanValue()) return [3 /*break*/, 3];
|
|
604
|
+
outputNode = context.outputNodeList[context.outputPosition] || output;
|
|
605
|
+
return [4 /*yield*/, this.xsltChildNodes(context, childNode, outputNode)];
|
|
606
|
+
case 2:
|
|
607
|
+
_b.sent();
|
|
608
|
+
return [3 /*break*/, 7];
|
|
609
|
+
case 3: return [3 /*break*/, 6];
|
|
610
|
+
case 4:
|
|
611
|
+
if (!this.isXsltElement(childNode, 'otherwise')) return [3 /*break*/, 6];
|
|
612
|
+
outputNode = context.outputNodeList[context.outputPosition] || output;
|
|
613
|
+
return [4 /*yield*/, this.xsltChildNodes(context, childNode, outputNode)];
|
|
614
|
+
case 5:
|
|
615
|
+
_b.sent();
|
|
616
|
+
return [3 /*break*/, 7];
|
|
617
|
+
case 6:
|
|
618
|
+
_i++;
|
|
619
|
+
return [3 /*break*/, 1];
|
|
620
|
+
case 7: return [2 /*return*/];
|
|
421
621
|
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
var outputNode = context.outputNodeList[context.outputPosition] || output;
|
|
425
|
-
this.xsltChildNodes(context, childNode, outputNode);
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
622
|
+
});
|
|
623
|
+
});
|
|
429
624
|
};
|
|
430
625
|
/**
|
|
431
626
|
* Implements `xsl:copy` for all node types.
|
|
@@ -484,33 +679,83 @@ var Xslt = /** @class */ (function () {
|
|
|
484
679
|
};
|
|
485
680
|
/**
|
|
486
681
|
* Implements `xsl:for-each`.
|
|
487
|
-
* @param
|
|
682
|
+
* @param context The Expression Context.
|
|
488
683
|
* @param template The template.
|
|
489
684
|
* @param output The output.
|
|
490
685
|
*/
|
|
491
686
|
Xslt.prototype.xsltForEach = function (context, template, output) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
687
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
688
|
+
var select, nodes, sortContext, nodesWithParent, i;
|
|
689
|
+
return __generator(this, function (_a) {
|
|
690
|
+
switch (_a.label) {
|
|
691
|
+
case 0:
|
|
692
|
+
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
693
|
+
nodes = this.xPath.xPathEval(select, context).nodeSetValue();
|
|
694
|
+
if (nodes.length === 0) {
|
|
695
|
+
return [2 /*return*/];
|
|
696
|
+
}
|
|
697
|
+
sortContext = context.clone(nodes);
|
|
698
|
+
this.xsltSort(sortContext, template);
|
|
699
|
+
nodesWithParent = sortContext.nodeList.filter(function (n) { return n.parentNode !== null && n.parentNode !== undefined; });
|
|
700
|
+
if (nodesWithParent.length <= 0) {
|
|
701
|
+
throw new Error('Nodes with no parents defined.');
|
|
702
|
+
}
|
|
703
|
+
i = 0;
|
|
704
|
+
_a.label = 1;
|
|
705
|
+
case 1:
|
|
706
|
+
if (!(i < sortContext.contextSize())) return [3 /*break*/, 4];
|
|
707
|
+
return [4 /*yield*/, this.xsltChildNodes(sortContext.clone(sortContext.nodeList, undefined, i), template, output)];
|
|
708
|
+
case 2:
|
|
709
|
+
_a.sent();
|
|
710
|
+
_a.label = 3;
|
|
711
|
+
case 3:
|
|
712
|
+
++i;
|
|
713
|
+
return [3 /*break*/, 1];
|
|
714
|
+
case 4: return [2 /*return*/];
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* Implements `xsl:include`.
|
|
721
|
+
* @param context The Expression Context.
|
|
722
|
+
* @param template The template.
|
|
723
|
+
* @param output The output.
|
|
724
|
+
*/
|
|
725
|
+
Xslt.prototype.xsltInclude = function (context, template, output) {
|
|
726
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
727
|
+
var hrefAttributeFind, hrefAttribute, fetchTest, fetchResponse, includedXslt;
|
|
728
|
+
return __generator(this, function (_a) {
|
|
729
|
+
switch (_a.label) {
|
|
730
|
+
case 0:
|
|
731
|
+
// We need to test here whether `window.fetch` is available or not.
|
|
732
|
+
// If it is a browser environemnt, it should be.
|
|
733
|
+
// Otherwise, we will need to import an equivalent library, like 'node-fetch'.
|
|
734
|
+
if (!global.globalThis.fetch) {
|
|
735
|
+
global.globalThis.fetch = node_fetch_1.default;
|
|
736
|
+
global.globalThis.Headers = node_fetch_1.Headers;
|
|
737
|
+
global.globalThis.Request = node_fetch_1.Request;
|
|
738
|
+
global.globalThis.Response = node_fetch_1.Response;
|
|
739
|
+
}
|
|
740
|
+
hrefAttributeFind = template.childNodes.filter(function (n) { return n.nodeName === 'href'; });
|
|
741
|
+
if (hrefAttributeFind.length <= 0) {
|
|
742
|
+
throw new Error('<xsl:include> with no href attribute defined.');
|
|
743
|
+
}
|
|
744
|
+
hrefAttribute = hrefAttributeFind[0];
|
|
745
|
+
return [4 /*yield*/, global.globalThis.fetch(hrefAttribute.nodeValue)];
|
|
746
|
+
case 1:
|
|
747
|
+
fetchTest = _a.sent();
|
|
748
|
+
return [4 /*yield*/, fetchTest.text()];
|
|
749
|
+
case 2:
|
|
750
|
+
fetchResponse = _a.sent();
|
|
751
|
+
includedXslt = this.xmlParser.xmlParse(fetchResponse);
|
|
752
|
+
return [4 /*yield*/, this.xsltChildNodes(context, includedXslt.childNodes[0], output)];
|
|
753
|
+
case 3:
|
|
754
|
+
_a.sent();
|
|
755
|
+
return [2 /*return*/];
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
});
|
|
514
759
|
};
|
|
515
760
|
/**
|
|
516
761
|
* Orders the current node list in the input context according to the
|
|
@@ -547,24 +792,35 @@ var Xslt = /** @class */ (function () {
|
|
|
547
792
|
* @param output The output XML.
|
|
548
793
|
*/
|
|
549
794
|
Xslt.prototype.xsltTransformOrStylesheet = function (template, context, output) {
|
|
550
|
-
|
|
551
|
-
var
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
795
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
796
|
+
var _i, _a, stylesheetAttribute;
|
|
797
|
+
return __generator(this, function (_b) {
|
|
798
|
+
switch (_b.label) {
|
|
799
|
+
case 0:
|
|
800
|
+
for (_i = 0, _a = template.childNodes.filter(function (n) { return n.nodeType === constants_1.DOM_ATTRIBUTE_NODE; }); _i < _a.length; _i++) {
|
|
801
|
+
stylesheetAttribute = _a[_i];
|
|
802
|
+
switch (stylesheetAttribute.nodeName) {
|
|
803
|
+
case 'version':
|
|
804
|
+
this.version = stylesheetAttribute.nodeValue;
|
|
805
|
+
if (!['1.0', '2.0', '3.0'].includes(this.version)) {
|
|
806
|
+
throw new Error("XSLT version not defined or invalid. Actual resolved version: ".concat(this.version || '(none)', "."));
|
|
807
|
+
}
|
|
808
|
+
context.xsltVersion = this.version;
|
|
809
|
+
break;
|
|
810
|
+
default:
|
|
811
|
+
if (stylesheetAttribute.prefix === 'xmlns') {
|
|
812
|
+
context.knownNamespaces[stylesheetAttribute.localName] = stylesheetAttribute.nodeValue;
|
|
813
|
+
}
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, output)];
|
|
818
|
+
case 1:
|
|
819
|
+
_b.sent();
|
|
820
|
+
return [2 /*return*/];
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
});
|
|
568
824
|
};
|
|
569
825
|
/**
|
|
570
826
|
* Evaluates a variable or parameter and set it in the current input
|
|
@@ -578,29 +834,42 @@ var Xslt = /** @class */ (function () {
|
|
|
578
834
|
* value. `xsl:variable` and `xsl:with-param` override; `xsl:param` doesn't.
|
|
579
835
|
*/
|
|
580
836
|
Xslt.prototype.xsltVariable = function (context, template, override) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
837
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
838
|
+
var name, select, value, nonAttributeChildren, root, parameterValue, filteredParameter;
|
|
839
|
+
return __generator(this, function (_a) {
|
|
840
|
+
switch (_a.label) {
|
|
841
|
+
case 0:
|
|
842
|
+
name = (0, dom_1.xmlGetAttribute)(template, 'name');
|
|
843
|
+
select = (0, dom_1.xmlGetAttribute)(template, 'select');
|
|
844
|
+
nonAttributeChildren = template.childNodes.filter(function (n) { return n.nodeType !== constants_1.DOM_ATTRIBUTE_NODE; });
|
|
845
|
+
if (!(nonAttributeChildren.length > 0)) return [3 /*break*/, 2];
|
|
846
|
+
root = (0, dom_1.domCreateDocumentFragment)(template.ownerDocument);
|
|
847
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, root)];
|
|
848
|
+
case 1:
|
|
849
|
+
_a.sent();
|
|
850
|
+
value = new values_1.NodeSetValue([root]);
|
|
851
|
+
return [3 /*break*/, 3];
|
|
852
|
+
case 2:
|
|
853
|
+
if (select) {
|
|
854
|
+
value = this.xPath.xPathEval(select, context);
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
parameterValue = '';
|
|
858
|
+
filteredParameter = this.options.parameters.filter(function (p) { return p.name === name; });
|
|
859
|
+
if (filteredParameter.length > 0) {
|
|
860
|
+
parameterValue = filteredParameter[0].value;
|
|
861
|
+
}
|
|
862
|
+
value = new values_1.StringValue(parameterValue);
|
|
863
|
+
}
|
|
864
|
+
_a.label = 3;
|
|
865
|
+
case 3:
|
|
866
|
+
if (override || !context.getVariable(name)) {
|
|
867
|
+
context.setVariable(name, value);
|
|
868
|
+
}
|
|
869
|
+
return [2 /*return*/];
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
});
|
|
604
873
|
};
|
|
605
874
|
/**
|
|
606
875
|
* Traverses the template node tree. Calls the main processing
|
|
@@ -611,12 +880,27 @@ var Xslt = /** @class */ (function () {
|
|
|
611
880
|
* @param output If set, the output where the transformation should occur.
|
|
612
881
|
*/
|
|
613
882
|
Xslt.prototype.xsltChildNodes = function (context, template, output) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
883
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
884
|
+
var contextClone, i;
|
|
885
|
+
return __generator(this, function (_a) {
|
|
886
|
+
switch (_a.label) {
|
|
887
|
+
case 0:
|
|
888
|
+
contextClone = context.clone();
|
|
889
|
+
i = 0;
|
|
890
|
+
_a.label = 1;
|
|
891
|
+
case 1:
|
|
892
|
+
if (!(i < template.childNodes.length)) return [3 /*break*/, 4];
|
|
893
|
+
return [4 /*yield*/, this.xsltProcessContext(contextClone, template.childNodes[i], output)];
|
|
894
|
+
case 2:
|
|
895
|
+
_a.sent();
|
|
896
|
+
_a.label = 3;
|
|
897
|
+
case 3:
|
|
898
|
+
++i;
|
|
899
|
+
return [3 /*break*/, 1];
|
|
900
|
+
case 4: return [2 /*return*/];
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
});
|
|
620
904
|
};
|
|
621
905
|
/**
|
|
622
906
|
* This logic is used in two different places:
|
|
@@ -624,6 +908,7 @@ var Xslt = /** @class */ (function () {
|
|
|
624
908
|
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
625
909
|
* @param context The Expression Context.
|
|
626
910
|
* @param template The template, that contains the node value to be written.
|
|
911
|
+
* @param output The output.
|
|
627
912
|
*/
|
|
628
913
|
Xslt.prototype.commonLogicTextNode = function (context, template, output) {
|
|
629
914
|
if (output.nodeType === constants_1.DOM_DOCUMENT_FRAGMENT_NODE) {
|
|
@@ -653,59 +938,74 @@ var Xslt = /** @class */ (function () {
|
|
|
653
938
|
* @param output The output.
|
|
654
939
|
*/
|
|
655
940
|
Xslt.prototype.xsltPassThrough = function (context, template, output) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
941
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
942
|
+
var node, elementContext, newNode, transformedAttributes, _i, transformedAttributes_1, previouslyTransformedAttribute, name_2, value, templateAttributes, _a, templateAttributes_1, attribute, name_3, value, outputNode, clonedContext;
|
|
943
|
+
return __generator(this, function (_b) {
|
|
944
|
+
switch (_b.label) {
|
|
945
|
+
case 0:
|
|
946
|
+
if (!(template.nodeType == constants_1.DOM_TEXT_NODE)) return [3 /*break*/, 1];
|
|
947
|
+
if (this.xsltPassText(template)) {
|
|
948
|
+
this.commonLogicTextNode(context, template, output);
|
|
949
|
+
}
|
|
950
|
+
return [3 /*break*/, 5];
|
|
951
|
+
case 1:
|
|
952
|
+
if (!(template.nodeType == constants_1.DOM_ELEMENT_NODE)) return [3 /*break*/, 3];
|
|
953
|
+
node = void 0;
|
|
954
|
+
elementContext = context;
|
|
955
|
+
if (context.nodeList[context.position].nodeName === '#document') {
|
|
956
|
+
node = context.nodeList[context.position].childNodes.find(function (c) { return c.nodeName !== '#dtd-section'; });
|
|
957
|
+
elementContext = context.clone([node]);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
node = context.nodeList[context.position];
|
|
961
|
+
}
|
|
962
|
+
newNode = void 0;
|
|
963
|
+
if (node.outputNode === undefined || node.outputNode === null || context.outputDepth > 0) {
|
|
964
|
+
newNode = (0, dom_1.domCreateElement)(this.outputDocument, template.nodeName);
|
|
965
|
+
newNode.siblingPosition = node.siblingPosition;
|
|
966
|
+
if (context.outputDepth === 0) {
|
|
967
|
+
node.outputNode = newNode;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
newNode = node.outputNode;
|
|
972
|
+
}
|
|
973
|
+
newNode.transformedNodeName = template.nodeName;
|
|
974
|
+
newNode.transformedLocalName = template.localName;
|
|
975
|
+
transformedAttributes = node.transformedChildNodes.filter(function (n) { return n.nodeType === constants_1.DOM_ATTRIBUTE_NODE; });
|
|
976
|
+
for (_i = 0, transformedAttributes_1 = transformedAttributes; _i < transformedAttributes_1.length; _i++) {
|
|
977
|
+
previouslyTransformedAttribute = transformedAttributes_1[_i];
|
|
978
|
+
name_2 = previouslyTransformedAttribute.transformedNodeName;
|
|
979
|
+
value = previouslyTransformedAttribute.transformedNodeValue;
|
|
980
|
+
(0, dom_1.domSetTransformedAttribute)(newNode, name_2, value);
|
|
981
|
+
}
|
|
982
|
+
templateAttributes = template.childNodes.filter(function (a) { return (a === null || a === void 0 ? void 0 : a.nodeType) === constants_1.DOM_ATTRIBUTE_NODE; });
|
|
983
|
+
for (_a = 0, templateAttributes_1 = templateAttributes; _a < templateAttributes_1.length; _a++) {
|
|
984
|
+
attribute = templateAttributes_1[_a];
|
|
985
|
+
name_3 = attribute.nodeName;
|
|
986
|
+
value = this.xsltAttributeValue(attribute.nodeValue, elementContext);
|
|
987
|
+
(0, dom_1.domSetTransformedAttribute)(newNode, name_3, value);
|
|
988
|
+
}
|
|
989
|
+
outputNode = context.outputNodeList[context.outputPosition];
|
|
990
|
+
(0, dom_1.domAppendTransformedChild)(outputNode, newNode);
|
|
991
|
+
clonedContext = elementContext.cloneByOutput(outputNode.transformedChildNodes, outputNode.transformedChildNodes.length - 1, ++elementContext.outputDepth);
|
|
992
|
+
return [4 /*yield*/, this.xsltChildNodes(clonedContext, template, output)];
|
|
993
|
+
case 2:
|
|
994
|
+
_b.sent();
|
|
995
|
+
return [3 /*break*/, 5];
|
|
996
|
+
case 3:
|
|
997
|
+
// This applies also to the DOCUMENT_NODE of the XSL stylesheet,
|
|
998
|
+
// so we don't have to treat it specially.
|
|
999
|
+
return [4 /*yield*/, this.xsltChildNodes(context, template, output)];
|
|
1000
|
+
case 4:
|
|
1001
|
+
// This applies also to the DOCUMENT_NODE of the XSL stylesheet,
|
|
1002
|
+
// so we don't have to treat it specially.
|
|
1003
|
+
_b.sent();
|
|
1004
|
+
_b.label = 5;
|
|
1005
|
+
case 5: return [2 /*return*/];
|
|
677
1006
|
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
newNode = node.outputNode;
|
|
681
|
-
}
|
|
682
|
-
newNode.transformedNodeName = template.nodeName;
|
|
683
|
-
newNode.transformedLocalName = template.localName;
|
|
684
|
-
// The node can have transformed attributes from previous transformations.
|
|
685
|
-
var transformedAttributes = node.transformedChildNodes.filter(function (n) { return n.nodeType === constants_1.DOM_ATTRIBUTE_NODE; });
|
|
686
|
-
for (var _i = 0, transformedAttributes_1 = transformedAttributes; _i < transformedAttributes_1.length; _i++) {
|
|
687
|
-
var previouslyTransformedAttribute = transformedAttributes_1[_i];
|
|
688
|
-
var name_2 = previouslyTransformedAttribute.transformedNodeName;
|
|
689
|
-
var value = previouslyTransformedAttribute.transformedNodeValue;
|
|
690
|
-
(0, dom_1.domSetTransformedAttribute)(newNode, name_2, value);
|
|
691
|
-
}
|
|
692
|
-
var templateAttributes = template.childNodes.filter(function (a) { return (a === null || a === void 0 ? void 0 : a.nodeType) === constants_1.DOM_ATTRIBUTE_NODE; });
|
|
693
|
-
for (var _a = 0, templateAttributes_1 = templateAttributes; _a < templateAttributes_1.length; _a++) {
|
|
694
|
-
var attribute = templateAttributes_1[_a];
|
|
695
|
-
var name_3 = attribute.nodeName;
|
|
696
|
-
var value = this.xsltAttributeValue(attribute.nodeValue, elementContext);
|
|
697
|
-
(0, dom_1.domSetTransformedAttribute)(newNode, name_3, value);
|
|
698
|
-
}
|
|
699
|
-
var outputNode = context.outputNodeList[context.outputPosition];
|
|
700
|
-
(0, dom_1.domAppendTransformedChild)(outputNode, newNode);
|
|
701
|
-
var clonedContext = elementContext.cloneByOutput(outputNode.transformedChildNodes, outputNode.transformedChildNodes.length - 1, ++elementContext.outputDepth);
|
|
702
|
-
this.xsltChildNodes(clonedContext, template, output);
|
|
703
|
-
}
|
|
704
|
-
else {
|
|
705
|
-
// This applies also to the DOCUMENT_NODE of the XSL stylesheet,
|
|
706
|
-
// so we don't have to treat it specially.
|
|
707
|
-
this.xsltChildNodes(context, template, output);
|
|
708
|
-
}
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
709
1009
|
};
|
|
710
1010
|
/**
|
|
711
1011
|
* Determines if a text node in the XSLT template document is to be
|
|
@@ -738,7 +1038,7 @@ var Xslt = /** @class */ (function () {
|
|
|
738
1038
|
}
|
|
739
1039
|
return false;
|
|
740
1040
|
};
|
|
741
|
-
Xslt.prototype.
|
|
1041
|
+
Xslt.prototype.findAttributeInContext = function (attributeName, context) {
|
|
742
1042
|
return context.nodeList[context.position].childNodes.find(function (a) { return a.nodeType === constants_1.DOM_ATTRIBUTE_NODE && a.nodeName === attributeName; });
|
|
743
1043
|
};
|
|
744
1044
|
/**
|
|
@@ -790,12 +1090,28 @@ var Xslt = /** @class */ (function () {
|
|
|
790
1090
|
* @param template The template node.
|
|
791
1091
|
*/
|
|
792
1092
|
Xslt.prototype.xsltWithParam = function (context, template) {
|
|
793
|
-
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1093
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1094
|
+
var _i, _a, childNode;
|
|
1095
|
+
return __generator(this, function (_b) {
|
|
1096
|
+
switch (_b.label) {
|
|
1097
|
+
case 0:
|
|
1098
|
+
_i = 0, _a = template.childNodes;
|
|
1099
|
+
_b.label = 1;
|
|
1100
|
+
case 1:
|
|
1101
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
1102
|
+
childNode = _a[_i];
|
|
1103
|
+
if (!(childNode.nodeType === constants_1.DOM_ELEMENT_NODE && this.isXsltElement(childNode, 'with-param'))) return [3 /*break*/, 3];
|
|
1104
|
+
return [4 /*yield*/, this.xsltVariable(context, childNode, true)];
|
|
1105
|
+
case 2:
|
|
1106
|
+
_b.sent();
|
|
1107
|
+
_b.label = 3;
|
|
1108
|
+
case 3:
|
|
1109
|
+
_i++;
|
|
1110
|
+
return [3 /*break*/, 1];
|
|
1111
|
+
case 4: return [2 /*return*/];
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
});
|
|
799
1115
|
};
|
|
800
1116
|
// Test if the given element is an XSLT element, optionally the one with the given name
|
|
801
1117
|
Xslt.prototype.isXsltElement = function (element, opt_wantedName) {
|