| Version 22 (modified by jean-gui, 3 years ago) |
|---|
The contract between the framework Unicorn and an observer is composed of two files located on observer side :
To learn more : http://www.w3.org/QA/Tools/Unicorn/contract/
observer.wadl
An xml file which has to be validated by the schema observer-response.xsd. This file tells to Unicorn
- what are possible input methods of the observer (input by URI?, by text? or by file?)
- what are possible parameters for each input method
- what is the type of the parameters
Some examples:
This contract usually has 2 main parts:
<application> <grammars> <xs:schema> ... Part 1: Declaration of types ... </xs:schema> </grammars> <resources> ... Part 2: Declaration of possible input methods and possible parameters for each method ... </resources> </application>
full source of observer.wadl
<?xml version="1.0" encoding="utf-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://research.sun.com/wadl wadl.xsd" xmlns="http://research.sun.com/wadl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:uco="http://www.w3.org/unicorn/observationresponse"> <xs:schema> <xs:element name="tX2"> <xs:complexType> <xs:choice> <xs:element name="0" /> <xs:element name="1" /> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <resources base="http://localhost/"> <resource uri="calculator.php"> <method name="GET" id="CalculatorGET"> <request> <query_variable name="uri" /> <query_variable name="x2" type="tX2"/> <query_variable name="xn"/> </request> </method> </resource> </resources> </application>
Explanation
- The first part defines a complex type tX2. A tX2 type can take only two values, 0 or 1.
- Inside <resources>..</ressources> tags, we define several ressources of our observer. In our case, we have just one resource, calculator.php, based on http://localhost/ (Full path of our observer will be http://localhost/calculator.php).
- Our observer have only one input method (read from an URI), so we have to define the only one entry <method>..</method>
There are two attributes for the tag <method> :
- name : GET or POST.
- id : method's key name. We'll use this id in observer.rdf.
This input method takes 3 parameters (of which two are optional).
- uri : path of a file which contains some simple arithmetic operations (notype define).
- x2 : (optional) it's a complex type to multiply results by 2 (which is declared in the first part).
- xn : (optional) to multiply results by n.
observer.rdf
This file contains all localized information, lists of mimetypes handled by each method of the observer and information about input parameter handle by the observer. This file has an ucn:Observer element which contains :
- A rdf:ID attribute as reference to the WADL file.
- Zero or more ucn:name elements as the name of the observer in different language.
- Zero or more ucn:description element to describe the observer in different language.
- Zero or more ucn:help element, link to a help page about the observer in different language.
- One or more ucn:inputMethod containing the exactly one ucn:Parameter itself containing One or more ucn:mimetype elements to define each mimetype handled by the method.
In our case we have just one method, CalculatorGET, which takes an uri containing text. So the mimetype will be text/plain.
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE owl [ <!ENTITY ucn "http://www.w3.org/unicorn"> <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns"> <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema"> ]> <rdf:RDF xmlns:rdf="&rdf;#" xmlns:rdfs="&rdfs;#" xmlns:ucn="&ucn;#" xmlns="&ucn;#" xml:base="&ucn;" > <ucn:Observer ucn:id="calculator" ucn:reference="calculator"> <ucn:name xml:lang="en">Calculator</ucn:name> <ucn:name xml:lang="fr">Calculatrice</ucn:name> <ucn:description xml:lang="en">An observer who evaluates simple arithmetic operations.</ucn:description> <ucn:description xml:lang="fr">Un observateur qui évalue des opérations arithmétiques.</ucn:description> <ucn:inputMethod> <ucn:ParameterURI ucn:methodName="CalculatorGET" ucn:parameterName="uri"> <ucn:mimetype>text/plain</ucn:mimetype> </ucn:ParameterURI> </ucn:inputMethod> </ucn:Observer> </rdf:RDF>
