# XLSForm expression delimiter syntax

**URL:** <https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634>\
**Category:** Ideas\
**Tags:** pyxform, form-design, odk-xforms, odk-xlsform\
**Created:** [October 1, 2026, 9:19am UTC](https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634 "2026-10-01T09:19:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lindsay\_Stevens\_Au](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@Lindsay\_Stevens\_Au](https://forum.getodk.org/u/Lindsay_Stevens_Au)\
**Post date:** [October 1, 2026, 9:19am UTC](https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634/1 "2026-10-01T09:19:04Z")

</div>

**What high-level problem are you trying to solve?**

Currently, in labels user can write `instance()` expressions to pipe data from other question responses or secondary instances (including entities) into a question or choice label (and a few other places). However, it can be difficult to reliably and quickly parse out where a complex `instance()` expression ends.

**Any ideas on how ODK could help you solve it?**

To solve this problem, and hopefully enable a lot of new and interesting features, a new expression delimiter syntax is proposed. The delimiter is double curly braces, reminiscent of Jinja or python f-strings. The delimiter can be escaped with a backslash.

The feature would support using variable references (e.g. `${my_question}`) inside and outside of the expression delimiter, and using multiple delimited expressions in a string. Another way to think of it is, a shortcut for adding a `calculate` then a variable reference, but with the tradeoff that the expression would (probably, not yet tested) be evaluated when the item is displayed, rather than when the source item is saved - though if that distinction matters, the `calculate` method can still be used.

Columns to which this applies (including translation variants) are as follows.

- survey: label, hint, guidance\_hint, constraint\_message, required\_message, image, big-image, audio, video.
- choices: label, image, audio, video (but not geometry).

The media columns are perhaps less straightforward since they still get a `jr://` prefix to the value - for that kind of use case there is this proposal: [Spec proposal: Media in external secondary intances](https://forum.getodk.org/t/spec-proposal-media-in-external-secondary-intances/58567)

Example:

```auto
Hello World! I can add: {{ 1 + 1 }}

```

This sort of thing would be processed into:

```auto
<label> Hello World! I can add: <output value=" 1 + 1 "/> </label>

```

Since form clients can evaluate `value` contents as an XPath expression, the displayed result would be:

```auto
Hello World! I can add: 2

```

Since this is XLSForm syntax around a XForms feature, users could try out this method by manually editing an XForm as shown above.

At some stage the current `instance()` parsing would be deprecated in favour of this new method. In that case, migration would involve wrapping such usages in the delimiters: `{{instance()}}`.

**Upload any helpful links, sketches, and videos.**

Current work in progress:

> <https://github.com/XLSForm/pyxform/pull/870>
>
> Closes #844
> Closes #704
> 
> \#### Why is this the best possible solution? Were an…y other approaches considered?
> 
> Design discussed in #844. There are a few related re-organisation commits but the main changes are in fc19c5ef.
> 
> Considered expanding existing \`instance()\` detection but the problem is accurately finding where the expression ends, seeing as it can be any valid XPath 1.0 expression (with ODK extensions). And anyway the new delimiter syntax allows for a much wider range of XPath expressions besides \`instance()\`.
> 
> A current limitation is that the processing happens in the Survey module, so parsing error messages aren't as nice as they could be. There's no exact row/column references or suggestion help text, the messages just say something went wrong and echo back the problem string. This could be improved in a follow-up PR.
> 
> \#### What are the regression risks?
> 
> Strings which contain (escaped) delimiter syntax in the relevant survey/choices text/media columns are now processed as if they use the new feature. This could be mitigated via a (temporary?) form-level setting to opt-out of the new expression delimiter processing. The existing \`instance()\` processing is retained (for now?) to reduce the urgency of updating existing forms.
> 
> \#### Does this change require updates to documentation? If so, please file an issue \[here\](https://github.com/XLSForm/xlsform.github.io) and include the link below.
> 
> Yes
> 
> \#### Before submitting this PR, please make sure you have:
> \- \[x\] included test cases for core behavior and edge cases in \`tests\`
> \- \[x\] run \`python -m unittest\` and verified all tests pass
> \- \[x\] run \`ruff format pyxform tests\` and \`ruff check pyxform tests\` to lint code
> \- \[x\] verified that any code or assets from external sources are properly credited in comments

---

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [October 1, 2026, 9:59am UTC](https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634/2 "2026-10-01T09:59:00Z")

</div>

I can think of many ways to use this already and it would clean up a bunch of calculations that are only used for note display too.

---

<div class="post-metadata">

**Author:** ![Stephen\_K\_ojwang](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/stephen_k_ojwang/32/7727_2.png) [@Stephen\_K\_ojwang](https://forum.getodk.org/u/Stephen_K_ojwang)\
**Post date:** [October 2, 2026, 10:00am UTC](https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634/3 "2026-10-02T10:00:23Z")

</div>

Sure, this inline evaluation will really save a lot of time and avoid unnecessary database fields. Many times I use calculation for conditionally display of a question for example same question with similar choice list but just needs the question label to be reframed differently depending on the respondent status. This occurs many times in field questionnaires.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [October 16, 2026, 6:45pm UTC](https://forum.getodk.org/t/xlsform-expression-delimiter-syntax/58634/4 "2026-10-16T18:45:03Z")

</div>

This functionality is now available on the [Web Forms preview](https://getodk.org/web-forms-preview/) and [XLSForm Online](https://getodk.org/xlsform/)! (We will eventually combine these two sites)

You can include any valid expression between {{ }} in any user-facing text, as described in @Lindsay_Stevens_Au's original post. If you want to use those literal values in your forms, you can escape them with backslashes: `\{{` and `\}}`.

Here's a sample form showing some of what you can do: [Expression substitution](https://docs.google.com/spreadsheets/d/1gveKh5oDHvYQRLp9-p__Y468UaQV85yYWbh7BIahLkQ/edit?gid=1068911091#gid=1068911091).

 ![Screenshot 2026-10-16 at 12.00.32 PM](https://getodk.b-cdn.net/uploads/default/original/3X/1/7/1700824088b6f037df2595a0eb6dce1726abe362.png)

Try it out and let us know what you think! We're currently planning for this to be released in early December.

I've already found [one bug with `<=` and `>=`](https://github.com/XLSForm/pyxform/issues/879). Who else is going bug hunting? 🔎 🕵️‍♀️
