diff --git a/src/main/java/org/javarosa/xform/parse/FormInstanceParser.java b/src/main/java/org/javarosa/xform/parse/FormInstanceParser.java index 2be1bdfef..53e5e3a0b 100644 --- a/src/main/java/org/javarosa/xform/parse/FormInstanceParser.java +++ b/src/main/java/org/javarosa/xform/parse/FormInstanceParser.java @@ -336,24 +336,24 @@ private void verifyItemsetBindings(FormInstance instance) { //make sure the labelref is tested against the right instance //check if it's not the main instance - DataInstance fi = null; + DataInstance secondaryInstance; if (itemset.labelRef.getInstanceName() != null) { - fi = formDef.getNonMainInstance(itemset.labelRef.getInstanceName()); - if (fi == null) { + secondaryInstance = formDef.getNonMainInstance(itemset.labelRef.getInstanceName()); + if (secondaryInstance == null) { throw new XFormParseException("Instance: " + itemset.labelRef.getInstanceName() + " Does not exists"); } } else { - fi = instance; + secondaryInstance = instance; } // Don't try to validate references if the external instance could not be resolved. We allow parsing a form // with placeholder external secondary instances for cases where a ReferenceManager can't be configured. - if (fi instanceof ExternalDataInstance && !((ExternalDataInstance) fi).isUsingPlaceholder()) { - if (fi.getTemplatePath(itemset.labelRef) == null) { + if (!(secondaryInstance instanceof ExternalDataInstance) || !((ExternalDataInstance) secondaryInstance).isUsingPlaceholder()) { + if (secondaryInstance.getTemplatePath(itemset.labelRef) == null) { throw new XFormParseException("