@getodk/xpath 0.5.0 → 0.6.0
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
|
@@ -5609,7 +5609,7 @@ const substring = new StringFunction(
|
|
|
5609
5609
|
return string2.substring(start, end);
|
|
5610
5610
|
}
|
|
5611
5611
|
);
|
|
5612
|
-
const string$
|
|
5612
|
+
const string$1 = new StringFunction(
|
|
5613
5613
|
"string",
|
|
5614
5614
|
[{ arityType: "optional" }],
|
|
5615
5615
|
(context, [expression]) => (expression?.evaluate(context) ?? context).toString()
|
|
@@ -5642,13 +5642,13 @@ const translate = new StringFunction(
|
|
|
5642
5642
|
}
|
|
5643
5643
|
);
|
|
5644
5644
|
|
|
5645
|
-
const string$
|
|
5645
|
+
const string$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
5646
5646
|
__proto__: null,
|
|
5647
5647
|
concat: concat$1,
|
|
5648
5648
|
contains,
|
|
5649
5649
|
normalizeSpace,
|
|
5650
5650
|
startsWith,
|
|
5651
|
-
string: string$
|
|
5651
|
+
string: string$1,
|
|
5652
5652
|
stringLength,
|
|
5653
5653
|
substring,
|
|
5654
5654
|
substringAfter,
|
|
@@ -5660,7 +5660,7 @@ const fn = new FunctionLibrary(FN_NAMESPACE_URI, [
|
|
|
5660
5660
|
...Object.values(boolean$2),
|
|
5661
5661
|
...Object.values(nodeset$1),
|
|
5662
5662
|
...Object.values(number$3),
|
|
5663
|
-
...Object.values(string$
|
|
5663
|
+
...Object.values(string$2)
|
|
5664
5664
|
]);
|
|
5665
5665
|
|
|
5666
5666
|
class BaseStep {
|
|
@@ -7443,21 +7443,21 @@ const enk = new FunctionLibrary(ENKETO_NAMESPACE_URI, [
|
|
|
7443
7443
|
new FunctionAlias("format-date", formatDateTime)
|
|
7444
7444
|
]);
|
|
7445
7445
|
|
|
7446
|
-
const itext = new
|
|
7446
|
+
const itext = new NodeSetFunction(
|
|
7447
7447
|
"itext",
|
|
7448
7448
|
[{ arityType: "required", typeHint: "string" }],
|
|
7449
7449
|
(context, [itextIDExpression]) => {
|
|
7450
7450
|
const itextID = itextIDExpression.evaluate(context).toString();
|
|
7451
|
-
return XFormsXPathEvaluator.
|
|
7451
|
+
return XFormsXPathEvaluator.getTranslationValues(context, itextID) ?? [];
|
|
7452
7452
|
}
|
|
7453
7453
|
);
|
|
7454
7454
|
|
|
7455
|
-
const
|
|
7455
|
+
const nodeSet = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
7456
7456
|
__proto__: null,
|
|
7457
7457
|
itext
|
|
7458
7458
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
7459
7459
|
|
|
7460
|
-
const jr = new FunctionLibrary(JAVAROSA_NAMESPACE_URI, [...Object.values(
|
|
7460
|
+
const jr = new FunctionLibrary(JAVAROSA_NAMESPACE_URI, [...Object.values(nodeSet)]);
|
|
7461
7461
|
|
|
7462
7462
|
const booleanFromString = new BooleanFunction(
|
|
7463
7463
|
"boolean-from-string",
|
|
@@ -15160,46 +15160,39 @@ class XFormsItextTranslations {
|
|
|
15160
15160
|
return textMap.get(itextID) ?? null;
|
|
15161
15161
|
}
|
|
15162
15162
|
/**
|
|
15163
|
+
* Retrieves all translation value elements for a given Itext in the active language.
|
|
15164
|
+
*
|
|
15163
15165
|
* @package
|
|
15164
15166
|
*
|
|
15165
|
-
*
|
|
15166
|
-
*
|
|
15167
|
+
* This method fetches the `text` element matching `itextID` and returns its child `value` elements,
|
|
15168
|
+
* which may have an optional `@form` attribute.
|
|
15169
|
+
*
|
|
15170
|
+
* The operation is conceptually similar to the following XPath query:
|
|
15167
15171
|
*
|
|
15168
15172
|
* ```xpath
|
|
15169
|
-
*
|
|
15170
|
-
*
|
|
15171
|
-
* xpath3-fn:environment-variable('activeLanguage')
|
|
15172
|
-
* )
|
|
15173
|
-
* /text[@id = $itextID]
|
|
15174
|
-
* /value[not(@form)]
|
|
15173
|
+
* imaginary:itext-translation(
|
|
15174
|
+
* xpath3-fn:environment-variable('activeLanguage')
|
|
15175
15175
|
* )
|
|
15176
|
+
* /text[@id = $itextID]
|
|
15177
|
+
* /value
|
|
15176
15178
|
* ```
|
|
15177
15179
|
*
|
|
15178
15180
|
* Or alternately:
|
|
15179
15181
|
*
|
|
15180
15182
|
* ```xpath
|
|
15181
|
-
*
|
|
15182
|
-
*
|
|
15183
|
-
* /
|
|
15184
|
-
* /
|
|
15185
|
-
* /value[not(@form)]
|
|
15186
|
-
* )
|
|
15183
|
+
* imaginary:itext-root()
|
|
15184
|
+
* /translation[@lang = xpath3-fn:environment-variable('activeLanguage')]
|
|
15185
|
+
* /text[@id = $itextID]
|
|
15186
|
+
* /value
|
|
15187
15187
|
* ```
|
|
15188
|
-
*
|
|
15189
|
-
* @todo The above really feels like it adds some helpful clarity to how `jr:itext()` is designed to work, and the kinds of structures, state and input involved. Since there's already some discomfort around that API as specified, it's worth considering
|
|
15188
|
+
* Returns an array of `XFormsItextTranslationValueElement<T>`
|
|
15190
15189
|
*/
|
|
15191
|
-
|
|
15190
|
+
getTranslationValues(itextID) {
|
|
15192
15191
|
const textElement = this.getTranslationTextElement(itextID);
|
|
15193
15192
|
if (textElement == null) {
|
|
15194
|
-
return
|
|
15195
|
-
}
|
|
15196
|
-
const { domProvider } = this;
|
|
15197
|
-
for (const valueElement of domProvider.getChildrenByLocalName(textElement, "value")) {
|
|
15198
|
-
if (!domProvider.hasLocalNamedAttribute(valueElement, "form")) {
|
|
15199
|
-
return domProvider.getNodeValue(valueElement);
|
|
15200
|
-
}
|
|
15193
|
+
return [];
|
|
15201
15194
|
}
|
|
15202
|
-
return "";
|
|
15195
|
+
return [...this.domProvider.getChildrenByLocalName(textElement, "value")];
|
|
15203
15196
|
}
|
|
15204
15197
|
getLanguages() {
|
|
15205
15198
|
return this.languages;
|
|
@@ -15236,9 +15229,9 @@ class XFormsXPathEvaluator extends Evaluator {
|
|
|
15236
15229
|
assertInternalXFormsXPathEvaluatorContext(context);
|
|
15237
15230
|
return context.evaluator.secondaryInstancesById.get(id) ?? null;
|
|
15238
15231
|
}
|
|
15239
|
-
static
|
|
15232
|
+
static getTranslationValues(context, itextID) {
|
|
15240
15233
|
assertInternalXFormsXPathEvaluatorContext(context);
|
|
15241
|
-
return context.evaluator.itextTranslations.
|
|
15234
|
+
return context.evaluator.itextTranslations.getTranslationValues(itextID);
|
|
15242
15235
|
}
|
|
15243
15236
|
rootNode;
|
|
15244
15237
|
/**
|