Introduction to scripting in Lumi Say

Created: - Updated:

Your survey does not have to present the same list of questions to every respondent, in the same order. You can define routing logic to control the flow of the questionnaire, making the path through the survey dynamic, based on the responses given. This knowledge base includes articles that can provide you with scripting techniques and explanations for each scenario you will likely encounter.

Lumi Say scripting is based on XML (Extensible Markup Language). If you are new to scripting, you should read the rest of this article, which provides a brief introduction to XML. For a more detailed description of the underlying XML, see Lumi Say XML Structure. For details of the Lumi Say XML editor, see Lumi Say XML editor.

Brief Introduction to XML

Note: This section covers the basics of XML. If you require more in-depth information about XML, please refer to w3schools, which has extensive information about XML: http://www.w3schools.com/xml/default.asp.

Extensible Mark-up Language (XML) is a mark-up language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.

Similarities and differences between XML and HTML

  • XML was designed to transport and store data while HTML was designed to display data. XML focuses on what data is, HTML focuses on how data looks
  • XML stands for Extensible Mark-up Language
  • XML is a mark-up language much like HTML
  • XML tags are not predefined. You must define your own tags
  • XML is designed to be self-descriptive
  • XML is a W3C Recommendation

XML Documents Form a Tree Structure

<root>
  <child>
    <subchild>..     ...</subchild>                                                     
  </child>
 </root>

Terminology

Tag

A mark-up construct that begins with < and ends with >, there are three types of tags:
Start tags, for example: <section>
End tags, for example: </section>
Empty element tags, for example: <line-break /> 

Element

 A logical document component either begins with a start-tag and ends with a matching end-tag or consists only of an empty-element tag. The characters between the start- and end-tags, if any, are the element's content, and may contain markup, including other elements, which are called child elements. An example of an element is:

<Greeting> Hello, world. </Greeting>. Another is <line-break />

Attribute

  A mark-up construct consists of a name and value pair that exists within a start-tag or empty-element tag. Example where number is the attribute and 3 is the value:

<step number="3">Connect A to B.</step>

XML Syntax Rules

In XML, it is illegal to omit the closing tag. All elements must have a closing tag:

<p>This is a paragraph.</p>                                                        
 <br />

 In XML, all elements must be properly nested within each other.

<root>
  <child>
    <subchild>.....</subchild>                                                         
  </child>
 </root>

In XML, the attribute values must always be quoted.

  <note date="12/03/2012">                                                           
 </note> 

Entity References

Some characters have a special meaning in XML. If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element. There are five predefined entity references in XML:

 Entity  Character Description

&lt;

<

Less than

&gt;

>

Greater than                                                          

&amp;

&

Ampersand

&apos;

'

Apostrophe

&quot;

"

Quotation mark