Skip to content
Mamadou Sy edited this page Mar 25, 2016 · 3 revisions

Generation Rules

This section describes the rules applied by the system to generate the ADX output and the behaviour of the local ADX properties.

Output selection rules

During the run-time, the system will evaluate the <condition> for each <output> in the order it is defined.

Once one <condition> is evaluated to True, then the system break the evaluation and used the <output> associated with the <condition>.

If none of the <condition> is evaluated to True then the system will use the <output> where the id matches the defaultOutput attribute of the <outputs> root element.

Examples:

<outputs defaultOutput="fallback">
  <output id="flash">
     <condition><![CDATA[ Browser.Support("Flash") And Browser.Support("Javascript") ]]></condition>
     <!-- ... contents ... -->
  </output>
  <output id="js">
      <condition><![CDATA[ Browser.Support("Javascript") ]]></condition>
      <!-- ... contents ... -->
  </output>
  <output id="fallback">
     <!-- ... contents ... -->
  </output>
</outputs>

If the browser supports Flash and Javascript, the “flash” output will be used.
If the browser supports Javascript but not Flash, the “js” output will be used.
If the browser doesn’t support Javascript nor Flash, the “fallback” output will be used.

<outputs defaultOutput="third">
   <output id="first">
      <condition><![CDATA[ False ]]></condition>
      <!-- ... contents ... -->
   </output>
   <output id="second">
      <condition><![CDATA[ True ]]></condition>
      <!-- ... contents ... -->
   </output>
   <output id="third">
      <condition><![CDATA[ True ]]></condition>
      <!-- ... contents ... -->
   </output>
</outputs>

The “first” output will not be used because it’s condition is false.
The “second” and “third” outputs return true, the “second” output will be used because it comes before the “third” output.

↑ Top of page ↑

Contents rules

There are mainly two types of contents in the ADX, the text-based content and the binary-based content.

The text-based content is any kind of file which contains raw text without rich formatting.
This type of file are editable in a text editor.
Be careful, all RTF-like documents are considered binary, this includes MS Word, WordPad documents, …

All other files are considered binary.

The ADX engine has built-in routines to manage common web contents (JavaScript, CSS, images, video, audio, flash).
All others non-managed contents require the usage of the <yield> or must have the attribute position set to “none”.

↑ Top of page ↑

Text content rules

<content type="text">

Text based content which doesn’t have a special insertion, it will be inserted as it is.
It is commonly use with the file extension *.txt, *.xml, *.json etc ….

It:

  • could be “static”, “share” or “dynamic”
  • must be associated with a text file.
  • doesn’t allow the usage of <attribute>

↑ Top of page ↑

HTML content rules

<content type="html">

Text-based content which doesn’t have a special insertion, it will be inserted as it is.

It:

  • could be “static”, “share” or “dynamic”
  • must be associated with text-based file
  • should be associated with an html file (*.html, *.htm).
  • doesn’t allow the usage of <attribute>

↑ Top of page ↑

Javascript content rules

<content type="javascript">

Text based content which have special insertions, according to his mode.
We recommend to set his position to `head` or `foot`, other positions are legals but not recommended.

It:

  • could be “static”, “share” or “dynamic”
  • must be associated with text-based file
  • should be associated with a javascript file (*.js)
  • allow the usage of the <attribute> , when no <yield> is specified.

When “static” or “share”, it produces the following code:

<script type="text/javascript" src="[PATH]"></script>

When “dynamic”, it produces the following code:

<script type="text/javascript">[CONTENT]</script>

↑ Top of page ↑

CSS content rules

<content type="css">

Text based content which have special insertions, according to his mode.
We recommend to set his position to `head`, other positions are authorised but not recommended.

It:

  • could be “static”, “share” or “dynamic”
  • must be associated with a text-based file
  • should be associated with a CSS file (*.css)
  • allow the usage of the <attribute> , when no <yield> is specified.

When “static” or “share”, it produces the following code:

<link type="text/css" rel="stylesheet" href="[PATH]" />

When “dynamic”, it produces the following code:

<style type="text/css">[CONTENT]</style>

↑ Top of page ↑

Binary content rules

<content type="binary">

Binary-based content which doesn’t have a special insertion.

It:

  • must be “static” or “share”
  • should be associated with a binary file.
  • doesn’t allow the usage of <attribute>.
  • require the usage of the <yield> or the position set to “none”.

↑ Top of page ↑

Image content rules

<content type="image">

Binary-based content which have a special insertion.
We recommend to set his position to `none`, `placeholder` or `foot`, other positions are legals but not recommended.

It:

  • must be “static” or “share”
  • must be associated with an image file (*.jpg, *.jpeg, *.png, *.gif …).
  • allow the usage of the <attribute> , when no <yield> is specified.

It produces the following code:

<img src="[PATH]" alt="" />

↑ Top of page ↑

Video content rules

<content type="video">

Binary-based content which have a special insertion.
We recommend to set his position to `none`, `placeholder` or `foot`, other positions are legals but not recommended.

It:

  • must be “static” or “share”
  • must be associated with a video file (*.ogv, *.ogg, *.mp4, *.webm …)
  • allow the usage of the <attribute> , when no <yield> is specified.

It produces the following code:

<video src="[PATH]"></video>

↑ Top of page ↑

Audio content rules

<content type="audio">

Binary-based content which have a special insertion.
We recommend to set his position to `none`, `placeholder` or `foot`, other positions are legals but not recommended.

It:

  • must be “static” or “share”
  • must be associated with an audio file (*.ogv, *.ogg, *.mp3, *.wav …)
  • allow the usage of the <attribute> , when no <yield> is specified.

It produces the following code:

<audio src="[PATH]"></audio>

↑ Top of page ↑

Flash content rules

<content type="flash">

Binary-based content which have a special insertion. We recommend to set his position to `none`, `placeholder` or `foot`, other positions are legals but not recommended.

It:

  • must be “static” or “share”
  • must be associated with a Adobe Flash file (*.swf)
  • doesn’t allow the usage of <attribute> , prefer the usage of <yield> instead.

It produces the following code:


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="[WIDTH]" height="[HEIGHT]">
    <param name="movie" value="[PATH]"/>
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="[PATH]" width="[WIDTH]" height="[HEIGHT]">
        <param name="movie" value="[PATH]"/>
    <!--<![endif]-->
        <a href="http://www.adobe.com/go/getflash">
            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
        </a>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
</object>

↑ Top of page ↑

Content attributes rules

Except for “text”, “binary”, “html” and “flash” content type, all other contents accept the overload of attributes of the auto-generated tag using the <attribute> element.

If <yield> element is present all <attribute> element are ignored.

In most cases, the system allows the overwrite of auto-generated attributes expect the one which specified the target file.
Below the table of the HTML attributes generated by the system with the indication about the ability to overwrite:

Content type Mode Attribute name Over-writable
javascript Static and share src Not over-writable
All mode type Over-writable
css Static and share href Not over-writable
rel Over-writable
All mode type Over-writable
image Static and share src Not over-writable
alt Over-writable
video Static and share src Not over-writable
audio Static and share src Not over-writable

↑ Top of page ↑

Output max iterations rules

This rule is specific for questions in a loop.

The ADC is responsible of the generation of controls, it may indicate to the rendering engine how many loop iterations it could managed for each output.
For example the ADC could manage an infinite number of iterations on desktop device, a maximum of 10 iterations on tablets and only 1 iteration at a time on mobile devices.

The user could also indicate the maximum number of iterations he wants to display on the page using the property askia-maxIterations (<property xsi:type="askiaProperty" id="askia-maxIterations">).

The system will take the minimum value between the attribute maxIterations of the <output> and the value specified by the user through the property askia-maxIterations (<property xsi:type="askiaProperty" id="askia-maxIterations">).

Because several questions could be merged into the same page, the rendering engine will generate expected iterations and stop immediately.
All following pages will generate all other expected iterations until the engine reaches the latest iteration, then it generates all remaining controls merged into the same page.

Below schemas of the generation, all questions are merged into the same page:

↑ Top of page ↑

Case 1. All iterations could be done in one page (maxIterations >= 5)

Survey structure:

  • Q1
  • Q2
  • Loop (5 items)
    • QLoop

Results:

  • Page 1:
    Q1 + Q2 + QLoop: All 5 iterations.

↑ Top of page ↑

Case 2. Questions before the loop (maxIterations = 5)

Survey structure:

  • Q1
  • Q2
  • Loop (15 items)
    • QLoop

Results:

  • Page 1:
    Q1 + Q2 + QLoop: 5 first iterations
  • Page 2:
    QLoop: 5 next iterations
  • Page 3:
    QLoop: 5 last iterations

↑ Top of page ↑

Case 3. Questions after the loop (maxIterations = 5)

Survey structure:

  • Loop (15 items)
    • QLoop
  • Q1
  • Q2

Results:

  • Page 1:
    QLoop: 5 first iterations
  • Page 2:
    QLoop: 5 next iterations
  • Page 3:
    QLoop: 5 last iterations + Q1 + Q2

↑ Top of page ↑

Case 4. Questions before and after the loop (maxIterations = 5)

Survey structure:

  • Q1
  • Q2
  • Loop (15 items)
    • QLoop
  • Q3
  • Q4

Results:

  • Page 1:
    Q1 + Q2 + QLoop: 5 first iterations
  • Page 2:
    QLoop: 5 next iterations
  • Page 3:
    QLoop: 5 last iterations + Q3 + Q4

↑ Top of page ↑

Case 5. Two loops on the same page (loop1: maxIterations = 5, loop2: maxIterations = 2)

Survey structure:

  • Loop1 (8 items)
    • QLoop1
  • Loop2 (4 items)
    • QLoop2

Results:

  • Page 1:
    QLoop1: 5 first iterations
  • Page 2:
    QLoop1: 3 last iterations + QLoop2: 2 first iterations
  • Page 3:
    QLoop2: 2 last iterations

↑ Top of page ↑

<< Master Page – Recommendations| Generate Askia HTML Inputs >>