Version 31 (modified by fbatard, 5 years ago)

--

Second Week for unicorn project : Formatting the tasklist

Possible changes to make to the tasklist.xml in order to enhance the flexibility with conditionnal checking.
We need to be able to have simple algorithms to define priorities in the tasklist.
These nodes will be placed into the task node for each task
Here are our first ideas about the new nodes to add.
The observer parts will remain unchanged for now except for the priority attribute.
We can delete the priority attribute in handle mimetype

A routine node to define the sequence to execute for this task :

  • Conditions are called using XPATH and refers to condition section
  • exec will execute the observer specified. As we call it with XPATH we can define a observation or a task -> inclusion of tasks -> recursivity
<routine>
   <if test="/conds/cond[@id=1]">
      <then>
          <exec value="/tasklist/observer/whatever">
          <exec value="/tasklist/observer/whatever2">
      </then>
      <else>
          <exec value="/tasklist/task/whatever3">
      </else>
    </if>
</routine>

Another idea proposed by Jean-Gui would be to create a switch keyword to deal with doctypes and mediatypes. This way we could create different routine depending on the type we find. Therefore the condition would be in the if tag :

 <if observer="rencardeur" test="p[class='doctype'] eq '-//W3C//DTD XHTML 1.0 Transitional//EN'">
 OR
<switch observer="rencardeur" result="passed">
     <case doctype="whatever">...</case>
     <case media="wtf.smil">..</case>
</switch>

The if tag might become so big when we want several doctypes and mediatypes. However the switch might be an option to consider seriously :P
You can see the third idea to have more details.

A cond will be placed here to be used in if command. It returns a boolean :

  • id to help calling the condition
  • result to know if we want it to pass or to fail
  • the list of doctypes that we want in it
  • the list of mediatypes we're looking for
<conds>
   <cond id="1" result="passed" observer="rencardeur">
      <doctypes>
           <doctype>whatever4.0</doctype>
           <doctype>and_so_on1.0Strict</doctype>
      <doctypes/>
      <mediatypes>
           <mediatype>svg</mediatype>
           <mediatype>html</mediatype>
      </mediatypes>
    </cond>
</conds>

Conds can be used in order to do the multi-threading. In the previous version there was 3 types of priority. To insert the multi-threading they just ran all the tasks which belonged to the same priority in a map. As the maps will disappear in the new version as well as the priorities, we thought this node conds would be an good way to deal with multi-threading. We can multi-thread easily all the sub-nodes defined in conds.

An outputseq will be placed to know the order of the output result display sequence :

  • id to give the order
  • and the name of the observation to display

This is to improve in order to check that it's well formed. For instance we shouldn't ask to display an observer that haven't been called due to conditional checking.

<outputseq>
     <tasksort rank="1">Observation_Name</tasksort>
     <tasksort rank="2">Observation_Name2</tasksort>
</outputseq>

To deal with the observer that will check the mediatypes and doctypes

We thought we could deal with it as it was already done using a new attribute for a task

<task ref="conformance" ui="none"/>

Second idea

We could re use the current priority properties. Let me explain:
We 'll consider the if condition as a high priority and what's in the condition , lower priority.
We can then build a whole map of different priorities and execute it as it's done currently.
Of course we 'll need to extend that idea to take into account the mediatypes and so on.

As we discussed it appears that this solution won't be possible. We can't keep the independance of the task and the mutiple 'if' insert .

Third idea

    <routine>
      <!-- 
           We first call an observer whose role is to get information on the document
           This type of observer's response is free, unicorn will use xpath to
           find what it needs 
      -->
      <observation ref="rencardeur"/>
      <if>
        <!-- OR is implied -->
        <cond type="mimetype" value="application/mathml+xml"/>
        <cond type="mimetype" value="application/smil+xml"/>
        <cond type="mimetype" value="application/xhtml+xml"/>
        <cond type="mimetype" value="image/svg+xml"/>
        <cond type="mimetype" value="text/html"/>
        <then>
          <if>
            <cond type="xpath" subject="rencardeur" value="(//doctype eq '-//W3C//DTD XHTML 1.0 Strict//EN')
                                                           or (//doctype eq '-//W3C//DTD HTML 4.01//EN')"/>
            <then>
              <observation ref="markup-validator"/>
              <if>
                <cond type="passed" value="markup-validator"/>
                <then>
                  <if>
                    <cond type="mimetype" value="text/html"/>
                    <then>
                      <observation ref="appc-checker"/>
                    </then>
                  </if>
                </then>
              </if>
            </then>
          </if>
        </then>
      </if>
      <if>
        <!-- OR -->
        <cond type="mimetype" value="text/css"/>
        <cond type="passed" value="markup-validator"/>
        <then>
          <observation ref="css-validator"/>
        </then>
      </if>
    </routine>

This could be factorized to use task inclusion:

    <routine id="html+css">
      <routine ref="html"/>
      <if>
        <!-- OR -->
        <cond type="mimetype" value="text/css"/>
        <cond type="passed" value="markup-validator"/>
        <then>
          <observation ref="css-validator"/>
        </then>
      </if>
    </routine>

And in an HTML task:

    <routine id="html">
      <observation ref="rencardeur"/>
      <if>
        <!-- OR is implied -->
        <cond type="mimetype" value="application/mathml+xml"/>
        <cond type="mimetype" value="application/smil+xml"/>
        <cond type="mimetype" value="application/xhtml+xml"/>
        <cond type="mimetype" value="image/svg+xml"/>
        <cond type="mimetype" value="text/html"/>
        <then>
          <if>
            <cond type="xpath" subject="rencardeur" value="(//doctype eq '-//W3C//DTD XHTML 1.0 Strict//EN')
                                                           or (//doctype eq '-//W3C//DTD HTML 4.01//EN')"/>
            <then>
              <observation ref="markup-validator"/>
              <if>
                <cond type="passed" value="markup-validator"/>
                <then>
                  <if>
                    <cond type="mimetype" value="text/html"/>
                    <then>
                      <observation ref="appc-checker"/>
                    </then>
                  </if>
                </then>
              </if>
            </then>
          </if>
        </then>
      </if>
    </routine>

Jonathan created a logo in his free time , check the attached files ;)

Attachments