Example of Notes Widget - XML

I would like to add some text to a page without any input from the user, possibly using the 'Note' type.

I have looked everywhere to find an example of the use of Notes, but I cannot find anything.

Any help would be greatly appreciated.

Thanks

Did you check this part of the documentation ?

And the "all widget xlsform example" at the top of the "question type" page ?

This is for xls format, I need an xml format example. The only way I'm able to link the bind to the instance is with an:

<input>
<label>Text I'd like to add</label>
</input>

But obviously this requires a user to input information. I just need to add some text without any input.

Sorry if this is a basic question, I'm quite new to xml and am reliant on the xforms examples. (https://getodk.github.io/xforms-spec/)

Thanks

Maybe am I misunderstanding your question but even if it is an "input" element, the user will not be prompt for any input.

Here is a basic xlsform with only one note element
note_widget.xlsx (50.4 KB)
And here its xml transformation

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" 
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml" 
xmlns:jr="http://openrosa.org/javarosa" 
xmlns:odk="http://www.opendatakit.org/xforms" 
xmlns:orx="http://openrosa.org/xforms" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>note example</h:title>
	<model odk:xforms-version="1.0.0">
		<instance>
			<data id="note_example" version="1">
				<intro/>
				<meta>
					<instanceID/>
				</meta>
			</data>
		</instance>
		<bind nodeset="/data/intro" readonly="true()" type="string"/>
		<bind jr:preload="uid" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
	</model>
</h:head>
<h:body>
	<input ref="/data/intro">
		<label>this is a note</label>
		<hint>this is the content of the note</hint>
	</input>
</h:body>
</h:html>

A 'note' in XML is really just a read-only text control; that is, a regular text input who's associated binding has readonly='true()'. So when the XForm client - ODK Collect or Enketo - gets a text question with read-only=true it says, "ah! this must be a note" and uses a slightly different widget to render it. The XForm spec itself doesn't have the concept of a note [if you were going display note-like stuff in HTML you'd probably just use a <p> element...], so its more like syntactic sugar just added by XLSForm.

2 Likes