Home   Documentation   Demonstrations   Download

AMICO: Documentation / AMICO Modules / Validator

 

While AMICO does not impose any limitations on semantics and syntax of data exchanged through the slots, we have provided several tools in order to enable check of validity of these messages. To do so, we have developed a AMICO constrains schema, and AMICO validator that can check if the messages send comply with defined syntactic and temporal constraints.

There are three basic types of AMICO constraints:

We use XML Schema for defining all of these constraints. Messages can be XML encoded, where we use XML schema for to check the whole message, or ordinary string, where we create a temporary XML document embedding data inside the XML document whose name is the same as the name of the variable. Syntax constraint is then defined as XML Schema element constraint, where the name of the element has to be the same as the name of the variable that we are checking. For example, XML schema constraint says that variable named 'size' can contain only numbers and parenthesis in specific pattern (for example, 12345-21 is valid, while 123456 is not a valid string).

    <xs:element name="size">

        <xs:simpleType>

            <xs:restriction base="xs:string">

                <xs:pattern value="\d{5}-d{2}" />

            </xs:restriction>

        </xs:simpleType>

    </xs:element>
 

For definition of the structural constraints, we where also able to reuse XML Schema language. Here, we do not go into the syntax of individual messages, but just in their ordering. When message are exchanged, we build an XML structure where names of XML elements are the same as the names of variables. This XML structure is then validated according to defined schema, using standard XML Schema validator. For example, following XSD fragments defines legal sequence of login messages,
making valid only three attempts to login:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

        <xs:import namespace="http://www.w3.org/XML/1998/namespace"

                        schemaLocation="http://www.w3.org/2001/xml.xs" />

    <xs:element name="variables">

        <xs:complexType>

            <xs:sequence minOccurs="1" maxOccurs="3">

                <xs:element name="user-name" type="xs:string" minOccurs="1"  maxOccurs="1">

                <xs:element name="user-name-response" type="xs:string" minOccurs="1"  maxOccurs="1"/>

                <xs:element name="password" type="xs:string" minOccurs="1"  maxOccurs="1"/>

                <xs:element name="password-response" type="xs:string" minOccurs="1"  maxOccurs="1"/>

            </xs:sequence>

        </xs:complexType>

    </xs:element>

    </xs:schema>


How To Run

     java -jar %AMICO_HOME%/bin/amico-validator.jar [<conf-url>]

 

 

Configuration

 

A main configuration file:
 

<?xml version="1.0" encoding="UTF-8"?>
<validator mode="timeout" timeout="10000">
<!-- A mode can be:

        - "immediate", validator is checking constraints as soon as new variable is updated.

        - "timeout", a validator logs the message updates in a XML structure, and analyze that structure after timeout time.

-->

  <communicator host="localhost" port="3320"/>   <!-- Optional. If omitted default settings will be used-->

      <variables> <!-- variables that will be validated -->

          <variable name="user-id" />

           <variable name="var1" />

           <variable name="var2" />

           <variable name="var3" />

           <variable name="birthday" />

           <variable name="faces" />

       </variables>

       <constraints>

           <constraint type="syntax" url="file:conf/modules/validator/test.xsd" />

           <constraint type="sequence" url="file:conf/modules/validator/sequence.xsd" />

       </constraints>

</validator>

 

An example of XML Schema defined constraint:
 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:import namespace="http://www.w3.org/XML/1998/namespace"
                    schemaLocation="http://www.w3.org/2001/xml.xs" />

        <xs:element name="variables">

            <xs:complexType>

                <xs:sequence minOccurs="0" maxOccurs="unbounded">

                    <xs:element name="var1">

                        <xs:complexType mixed="true">

                            <xs:attribute name="time">

                                <xs:simpleType>

                                    <xs:restriction base="xs:positiveInteger">

                                        <xs:maxExclusive value="10000" />

                                    </xs:restriction>

                                </xs:simpleType>

                            </xs:attribute>

                        </xs:complexType>

                    </xs:element>

                    <xs:element name="var2" type="xs:anyType" minOccurs="0" />

                    <xs:element name="var3" type="xs:anyType" minOccurs="0" />

                </xs:sequence>

            </xs:complexType>

        </xs:element>

  </xs:schema>