xslt-processor 5.0.6 → 5.0.7

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.js CHANGED
@@ -811,11 +811,45 @@ var init_filter_expression = __esm({
811
811
  }
812
812
  });
813
813
 
814
+ // src/xpath/lib/src/expressions/node-utils.ts
815
+ function getStringValueFromNode(node) {
816
+ var _a;
817
+ if (node === null || node === void 0) return null;
818
+ if (typeof node !== "object") return null;
819
+ if (typeof node.nodeType !== "number") return null;
820
+ if (node.nodeType === 3 || node.nodeType === 2) {
821
+ const v = node.nodeValue;
822
+ return v !== null && v !== void 0 && v !== "null" ? String(v) : "";
823
+ }
824
+ if (node.nodeType === 1 || node.nodeType === 9) {
825
+ const children = node.childNodes;
826
+ if (!children || children.length === 0) return "";
827
+ let text = "";
828
+ for (const child of children) {
829
+ if (child.nodeType === 3) {
830
+ const v = child.nodeValue;
831
+ if (v !== null && v !== void 0 && v !== "null") {
832
+ text += String(v);
833
+ }
834
+ } else if (child.nodeType === 1) {
835
+ text += (_a = getStringValueFromNode(child)) != null ? _a : "";
836
+ }
837
+ }
838
+ return text;
839
+ }
840
+ return null;
841
+ }
842
+ var init_node_utils = __esm({
843
+ "src/xpath/lib/src/expressions/node-utils.ts"() {
844
+ }
845
+ });
846
+
814
847
  // src/xpath/lib/src/expressions/unary-expression.ts
815
848
  var XPathUnaryExpression;
816
849
  var init_unary_expression = __esm({
817
850
  "src/xpath/lib/src/expressions/unary-expression.ts"() {
818
851
  init_expression();
852
+ init_node_utils();
819
853
  XPathUnaryExpression = class extends XPathExpression {
820
854
  constructor(operator, operand) {
821
855
  super();
@@ -843,12 +877,14 @@ var init_unary_expression = __esm({
843
877
  return null;
844
878
  }
845
879
  if (!Array.isArray(value)) {
880
+ const text = getStringValueFromNode(value);
881
+ if (text !== null) return text;
846
882
  return value;
847
883
  }
848
884
  if (value.length === 0) {
849
885
  return null;
850
886
  }
851
- return value[0];
887
+ return this.atomize(value[0]);
852
888
  }
853
889
  /**
854
890
  * Convert atomic value to number following XPath 2.0 rules
@@ -989,6 +1025,7 @@ var XPathArithmeticExpression;
989
1025
  var init_arithmetic_expression = __esm({
990
1026
  "src/xpath/lib/src/expressions/arithmetic-expression.ts"() {
991
1027
  init_expression();
1028
+ init_node_utils();
992
1029
  XPathArithmeticExpression = class extends XPathExpression {
993
1030
  constructor(left, right, operator) {
994
1031
  super();
@@ -1042,6 +1079,8 @@ var init_arithmetic_expression = __esm({
1042
1079
  return value.numberValue();
1043
1080
  }
1044
1081
  if (!Array.isArray(value)) {
1082
+ const text = getStringValueFromNode(value);
1083
+ if (text !== null) return text;
1045
1084
  return value;
1046
1085
  }
1047
1086
  if (value.length === 0) {