xslt-processor 5.0.3 → 5.0.4
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/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -12
- package/dist/index.mjs.map +1 -1
- package/dist/umd/xslt-processor.global.js +5 -5
- package/dist/umd/xslt-processor.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1263,6 +1263,12 @@ declare class Xslt {
|
|
|
1263
1263
|
* @param template The template.
|
|
1264
1264
|
*/
|
|
1265
1265
|
protected xsltKey(context: ExprContext, template: XNode): void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Returns all descendant nodes of the given node, depth-first.
|
|
1268
|
+
* @param node The root node to traverse from.
|
|
1269
|
+
* @returns All descendant nodes.
|
|
1270
|
+
*/
|
|
1271
|
+
private collectAllDescendants;
|
|
1266
1272
|
/**
|
|
1267
1273
|
* Implements `xsl:message`.
|
|
1268
1274
|
* Outputs a message to the console. If terminate="yes", throws an error to stop processing.
|
package/dist/index.d.ts
CHANGED
|
@@ -1263,6 +1263,12 @@ declare class Xslt {
|
|
|
1263
1263
|
* @param template The template.
|
|
1264
1264
|
*/
|
|
1265
1265
|
protected xsltKey(context: ExprContext, template: XNode): void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Returns all descendant nodes of the given node, depth-first.
|
|
1268
|
+
* @param node The root node to traverse from.
|
|
1269
|
+
* @returns All descendant nodes.
|
|
1270
|
+
*/
|
|
1271
|
+
private collectAllDescendants;
|
|
1266
1272
|
/**
|
|
1267
1273
|
* Implements `xsl:message`.
|
|
1268
1274
|
* Outputs a message to the console. If terminate="yes", throws an error to stop processing.
|
package/dist/index.js
CHANGED
|
@@ -16226,23 +16226,36 @@ var Xslt = class {
|
|
|
16226
16226
|
errorMessage = errorMessage.slice(0, -2);
|
|
16227
16227
|
throw new Error(errorMessage);
|
|
16228
16228
|
}
|
|
16229
|
-
let keyContext;
|
|
16230
|
-
if (context.nodeList[context.position].nodeName === "#document") {
|
|
16231
|
-
keyContext = context.clone(context.nodeList[context.position].childNodes);
|
|
16232
|
-
} else {
|
|
16233
|
-
keyContext = context;
|
|
16234
|
-
}
|
|
16235
|
-
const nodes = this.xsltMatch(match, keyContext);
|
|
16236
16229
|
if (!(name in context.keys)) {
|
|
16237
16230
|
context.keys[name] = {};
|
|
16238
16231
|
}
|
|
16239
|
-
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
|
|
16243
|
-
|
|
16232
|
+
const allNodes = this.collectAllDescendants(context.root);
|
|
16233
|
+
for (const node of allNodes) {
|
|
16234
|
+
if (nodeMatchesPattern(node, match, context, this.matchResolver, this.xPath)) {
|
|
16235
|
+
const nodeContext = context.clone([node]);
|
|
16236
|
+
const attribute = this.xPath.xPathEval(use, nodeContext);
|
|
16237
|
+
const attributeValue = attribute.stringValue();
|
|
16238
|
+
if (!(attributeValue in context.keys[name])) {
|
|
16239
|
+
context.keys[name][attributeValue] = new NodeSetValue([node]);
|
|
16240
|
+
} else {
|
|
16241
|
+
context.keys[name][attributeValue].nodeSetValue().push(node);
|
|
16242
|
+
}
|
|
16243
|
+
}
|
|
16244
16244
|
}
|
|
16245
16245
|
}
|
|
16246
|
+
/**
|
|
16247
|
+
* Returns all descendant nodes of the given node, depth-first.
|
|
16248
|
+
* @param node The root node to traverse from.
|
|
16249
|
+
* @returns All descendant nodes.
|
|
16250
|
+
*/
|
|
16251
|
+
collectAllDescendants(node) {
|
|
16252
|
+
const result = [];
|
|
16253
|
+
for (const child of node.childNodes || []) {
|
|
16254
|
+
result.push(child);
|
|
16255
|
+
result.push(...this.collectAllDescendants(child));
|
|
16256
|
+
}
|
|
16257
|
+
return result;
|
|
16258
|
+
}
|
|
16246
16259
|
/**
|
|
16247
16260
|
* Implements `xsl:message`.
|
|
16248
16261
|
* Outputs a message to the console. If terminate="yes", throws an error to stop processing.
|