diff --git a/pyxform/survey.py b/pyxform/survey.py index 4a43c3a8..19b69d06 100644 --- a/pyxform/survey.py +++ b/pyxform/survey.py @@ -1073,11 +1073,14 @@ def _var_repl_output_function(matchobj): # need to make sure we have reason to replace # since at this point < is <, # the net effect < gets translated again to &lt; - if "{" in original_xml: - pass_1 = instance_expression.replace_with_output(original_xml, context, self) - pass_2 = re.sub(BRACKETED_TAG_REGEX, _var_repl_output_function, pass_1) - return pass_2, not pass_2 == original_xml - return text, False + xml_text = instance_expression.replace_with_output(original_xml, context, self) + if "{" in xml_text: + xml_text = re.sub(BRACKETED_TAG_REGEX, _var_repl_output_function, xml_text) + changed = xml_text != original_xml + if changed: + return xml_text, True + else: + return text, False # pylint: disable=too-many-arguments def print_xform_to_file( diff --git a/tests/test_notes.py b/tests/test_notes.py index 42ef2b06..9c8e24f9 100644 --- a/tests/test_notes.py +++ b/tests/test_notes.py @@ -104,6 +104,12 @@ def test_instance_expression__permutations(self): "instance('c2')/root/item[contains(name, instance('c1')/root/item[name = /test_name/q1 ]/label)]/label" }, ), + # Instance expression with predicate not using a pyxform token. + Case( + "instance('c1')/root/item[name = 'y']/label", + xpq.body_input_label_output_value("note"), + {"instance('c1')/root/item[name = 'y']/label"}, + ), ] wrap_scenarios = ("{}", "Text {}", "{} text", "Text {} text") # All cases together in one.