xslt-processor 5.0.9 → 5.0.11

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.mjs CHANGED
@@ -9069,13 +9069,9 @@ var XPathBaseParser = class {
9069
9069
  return expr;
9070
9070
  }
9071
9071
  parsePrimaryExpr() {
9072
- var _a, _b, _c;
9072
+ var _a, _b;
9073
9073
  if (this.match("DOLLAR")) {
9074
- const next = this.peek();
9075
- if (!next || !this.isNcNameToken(next.type)) {
9076
- throw grammarViolation(`Expected variable name after $. Got: ${(_a = next == null ? void 0 : next.lexeme) != null ? _a : "EOF"}`);
9077
- }
9078
- const name = this.advance().lexeme;
9074
+ const name = this.parseVariableReferenceName();
9079
9075
  return new XPathVariableReference(name);
9080
9076
  }
9081
9077
  if (this.match("OPEN_PAREN")) {
@@ -9099,7 +9095,7 @@ var XPathBaseParser = class {
9099
9095
  return this.parseFunctionCall();
9100
9096
  }
9101
9097
  throw grammarViolation(
9102
- `Unexpected token in primary expression: ${(_c = (_b = this.peek()) == null ? void 0 : _b.lexeme) != null ? _c : "EOF"}`
9098
+ `Unexpected token in primary expression: ${(_b = (_a = this.peek()) == null ? void 0 : _a.lexeme) != null ? _b : "EOF"}`
9103
9099
  );
9104
9100
  }
9105
9101
  parseFunctionCall() {
@@ -9171,8 +9167,29 @@ var XPathBaseParser = class {
9171
9167
  isFunctionNameToken(type) {
9172
9168
  return type === "IDENTIFIER" || type === "FUNCTION" || type === "OPERATOR" || type === "LOCATION" || type === "EQNAME";
9173
9169
  }
9170
+ parseVariableReferenceName() {
9171
+ var _a, _b;
9172
+ if (this.check("EQNAME")) {
9173
+ return this.advance().lexeme;
9174
+ }
9175
+ const next = this.peek();
9176
+ if (!next || !this.isNcNameToken(next.type)) {
9177
+ throw grammarViolation(`Expected variable name after $. Got: ${(_a = next == null ? void 0 : next.lexeme) != null ? _a : "EOF"}`);
9178
+ }
9179
+ let name = this.advance().lexeme;
9180
+ if (this.match("COLON")) {
9181
+ const local = this.peek();
9182
+ if (!local || !this.isNcNameToken(local.type)) {
9183
+ throw grammarViolation(
9184
+ `Expected local name after namespace prefix in variable reference. Got: ${(_b = local == null ? void 0 : local.lexeme) != null ? _b : "EOF"}`
9185
+ );
9186
+ }
9187
+ name = `${name}:${this.advance().lexeme}`;
9188
+ }
9189
+ return name;
9190
+ }
9174
9191
  isNcNameToken(type) {
9175
- return type === "IDENTIFIER" || type === "FUNCTION" || type === "OPERATOR" || type === "LOCATION" || type === "NODE_TYPE";
9192
+ return type === "IDENTIFIER" || type === "FUNCTION" || type === "OPERATOR" || type === "LOCATION" || type === "NODE_TYPE" || type === "RESERVED_WORD";
9176
9193
  }
9177
9194
  parseNameOrWildcard() {
9178
9195
  let name = "";
@@ -9283,16 +9300,12 @@ var XPath20Parser = class extends XPathBaseParser {
9283
9300
  return left;
9284
9301
  }
9285
9302
  parsePrimaryExpr() {
9286
- var _a, _b;
9287
9303
  if (this.check("RESERVED_WORD") && this.peek().lexeme === "if") {
9288
9304
  return this.parseIfExpr();
9289
9305
  }
9290
9306
  if (this.check("DOLLAR")) {
9291
9307
  this.advance();
9292
- if (!this.isNameToken()) {
9293
- throw new Error(`Expected variable name after $. Got: ${(_b = (_a = this.peek()) == null ? void 0 : _a.lexeme) != null ? _b : "EOF"}`);
9294
- }
9295
- const name = this.advance().lexeme;
9308
+ const name = this.parseVariableReferenceName();
9296
9309
  return new XPathVariableReference(name);
9297
9310
  }
9298
9311
  return super.parsePrimaryExpr();
@@ -9669,7 +9682,7 @@ var XPath30Parser = class extends XPath20Parser {
9669
9682
  let args = [];
9670
9683
  if (this.check("DOLLAR")) {
9671
9684
  this.advance();
9672
- const varName = this.consume("IDENTIFIER", "Expected variable name after $").lexeme;
9685
+ const varName = this.parseVariableReferenceName();
9673
9686
  funcExpr = new XPathVariableReference(varName);
9674
9687
  this.consume(
9675
9688
  "OPEN_PAREN",
@@ -9737,8 +9750,7 @@ var XPath30Parser = class extends XPath20Parser {
9737
9750
  return this.parseStringTemplateFromLexeme(template);
9738
9751
  }
9739
9752
  if (this.match("DOLLAR")) {
9740
- const nameToken = this.consumeNameTokenInternal("Expected variable name after $");
9741
- return new XPathVariableReference(nameToken.lexeme);
9753
+ return new XPathVariableReference(this.parseVariableReferenceName());
9742
9754
  }
9743
9755
  if (this.checkReservedWordInternal("function")) {
9744
9756
  return this.parseInlineFunction();
@@ -15221,10 +15233,6 @@ var Xslt = class {
15221
15233
  }
15222
15234
  const sortContext = context.clone(nodes);
15223
15235
  this.xsltSort(sortContext, template);
15224
- const nodesWithParent = sortContext.nodeList.filter((n) => n.parentNode !== null && n.parentNode !== void 0);
15225
- if (nodesWithParent.length <= 0) {
15226
- throw new Error("Nodes with no parents defined.");
15227
- }
15228
15236
  for (let i = 0; i < sortContext.contextSize(); ++i) {
15229
15237
  yield this.xsltChildNodesExcludingConditional(
15230
15238
  sortContext.clone(sortContext.nodeList, i),
@@ -15487,7 +15495,7 @@ var Xslt = class {
15487
15495
  );
15488
15496
  if (onCompletionElements.length > 0) {
15489
15497
  const onCompletion = onCompletionElements[0];
15490
- const completionContext = context.clone([], 0);
15498
+ const completionContext = context.clone();
15491
15499
  for (const accName in accumulators) {
15492
15500
  completionContext.variables[accName] = accumulators[accName];
15493
15501
  }