Compare ODK text widget with appearance numbers with integer widget or decimal widget

(Ya Basha) #1

Hi Guys,

I am coding xlsforms and I want to know what is the technical comparison between a text widget with numbers appearance and integer or decimal widget, I found in odk documentation:
"A numerical input that treats the input as a string, rather than a number.
It can also be used in place of the Integer widget or Decimal widget if large numbers are needed."

I want to know the memory size and the processing that it takes and when storing the data are they (text appearance numbers, integer, or decimal) stored as strings or as the type of the widget.

Please Advice,

(Dr. Gareth S. Bestor) #2

Everything in the XML XForm (eg any default values), and everything transmitted as part of the XML submission payload, is represented (in XML) as a string. eg the number 123 is stored as "123", pi would be submitted as "3.1415", etc. How these end up being actually stored in a backend database after submission is somewhat dependent on the underlying database.

Hope that helps answer your question.

BTW, love the avatar! :slight_smile:

(Lloyd Owen Banwart) #3

I'm not sure if this is the root of your question, but I have found a need to use the 'text' widget with numbers appearance for very large numbers and phone numbers. The 'integer' widget has a limit of 9 characters. I'm not sure of the text or decimal widget character limit.

(Dr. Gareth S. Bestor) #4

Correct. Irrespective of how the raw data is expressed in XML, Widgets themselves will be limited by their underlying datatype (double, float, etc). So for very long/large numbers, you may have to explicitly enter them as a string instead (appearance="numbers" really just selects the keyboard - its still basically a 'string'...).

Although XML can represent strings of arbitrary length, the default ODK max string length is 255 characters as consequence of how string are stored in the backend Aggregate database. If you need to exceed this, you must do so explicitly with the odk:length modifier on the question field.