Skip to content

NumberFormatException when using pulldata with geotrace/geoshape #96

@sadiqkhoja

Description

@sadiqkhoja

Software versions

ODK-Validate-v1.19.2
openjdk 22.0.2 2024-07-16

Problem description

ODK Validation fails with the following error when bind type is geotrace or geotrace and its calculate attribute directly or indirectly calls pulldata():

Error
Validating: /Users/sadiq/Downloads/properties_error.xml


>> Something broke the parser.
java.lang.RuntimeException: Error evaluating field 'property' (/data/general_info[1]/property[1]): For input string: "properties"
        at org.javarosa.core.model.TriggerableDag.evaluateTriggerable(TriggerableDag.java:568)
        at org.javarosa.core.model.TriggerableDag.doEvaluateTriggerables(TriggerableDag.java:542)
        at org.javarosa.core.model.TriggerableDag.initializeTriggerables(TriggerableDag.java:465)
        at org.javarosa.core.model.TriggerableDag.initializeTriggerables(TriggerableDag.java:448)
        at org.javarosa.core.model.FormDef.initializeTriggerables(FormDef.java:709)
        at org.javarosa.core.model.FormDef.initialize(FormDef.java:1111)
        at org.opendatakit.validate.FormValidator.validate(FormValidator.java:497)
        at org.opendatakit.validate.FormValidator.validate(FormValidator.java:420)
        at org.opendatakit.validate.FormValidator.validate(FormValidator.java:392)
        at org.opendatakit.validate.FormValidator.validateAndExitWithErrorCode(FormValidator.java:349)
        at org.opendatakit.validate.FormValidator.main(FormValidator.java:141)
Caused by: java.lang.NumberFormatException: For input string: "properties"
        at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
        at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.base/java.lang.Double.parseDouble(Double.java:938)
        at org.javarosa.core.model.data.GeoPointData.cast(GeoPointData.java:164)
        at org.javarosa.core.model.data.GeoShapeData.cast(GeoShapeData.java:172)
        at org.javarosa.core.model.data.IAnswerData.wrapData(IAnswerData.java:103)
        at org.javarosa.core.model.condition.Recalculate.apply(Recalculate.java:60)
        at org.javarosa.core.model.condition.Triggerable.apply(Triggerable.java:127)
        at org.javarosa.core.model.QuickTriggerable.apply(QuickTriggerable.java:41)
        at org.javarosa.core.model.TriggerableDag.evaluateTriggerable(TriggerableDag.java:566)
        ... 10 more

The following files failed validation:
/Users/sadiq/Downloads/properties_error.xml

Result: Invalid

Steps to reproduce the problem

Example Form:
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms"
  xmlns:odk="http://www.opendatakit.org/xforms">
  <h:head>
    <h:title>properties</h:title>
    <model odk:xforms-version="1.0.0">
      <instance>
        <data id="properties_error" version="20241024131522">
          <general_info>
            <id />
            <cal_polygon />
            <property />
          </general_info>
          <meta>
            <instanceID />
          </meta>
        </data>
      </instance>
      <instance id="properties" src="jr://file-csv/properties.csv" />
      <instance id="ced">
        <root>
          <item>
            <name>52662599</name>
            <label>52662599</label>
          </item>
          <item>
            <name>1054542828</name>
            <label>1054542828</label>
          </item>
        </root>
      </instance>
      <bind nodeset="/data/general_info/id" type="string" required="true()" />
      <bind nodeset="/data/general_info/cal_polygon" type="string"
        calculate="pulldata('properties', 'polygon', 'id',  /data/general_info/id )" />
      <bind nodeset="/data/general_info/property" type="geoshape" readonly="true()"
        calculate=" /data/general_info/cal_polygon " />
      <bind nodeset="/data/meta/instanceID" type="string" readonly="true()" jr:preload="uid" />
    </model>
  </h:head>
  <h:body>
    <group ref="/data/general_info">
      <label>General Information</label>
      <select1 ref="/data/general_info/id">
        <label>ID Number</label>
        <itemset nodeset="instance('ced')/root/item">
          <value ref="name" />
          <label ref="label" />
        </itemset>
      </select1>
      <input appearance="hide-input" ref="/data/general_info/property">
        <label>Property</label>
      </input>
    </group>
  </h:body>
</h:html>

Expected behavior

It should return "Xform is valid!"

Other information

Originally posted in the ODK Forum https://forum.getodk.org/t/preload-multiple-polygons-and-display-them-in-the-odk-collection-application/50310/1

This issue is impacting ODK Central and pyxform, however we have a workaround to avoid pulldata and use xpath expression for list lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions