SHAME - Standardized Hyper Adaptible Metadata Editor

Example 4 - Using formlets

A formlet is small and modularized annotation profile that consists of a graph pattern and a form template. It might also contain a list of vocabularies / ontologies to populate drop-down menues.

Formlets are either atomic or compound. Atomic formlets explicitly gives the graph pattern, the form template, and the list of vocabularies / ontologies to use. Compound formlets, on the other hand, allows you to aggregate formlets and the resulting graph pattern, form template, and the list of vocabularies / ontologies to use are calculated from the parts. A reccomended approach is to provide small but independent formlets, typically representing a specific metadata field, such as a Dublin Core title, that can be reused in many situations. A set of atomic and compound formlets that belong together are managed in a formlet set. Lets consider some formlet provided in the SDC (Simple Dublin Core) formlet set:

An atomic formlet expressed in RDF/XML

Below follows an atomic formlet that captures the Dublin Core type property. The graph pattern, form template and vocabularies / ontologies are assumed to be uniquely identifiable in files which are refferred to by relative paths (from the directory where the formlet set resides) or absolute URLs. Typically the formlet set is expressed in a file named formlets.rdf and all graph pattern and form templates are in the same directory. In the example above the DCMIType vocabulary resides in the file dctype.rdf which is in another directory. Observe that every formlet has to have a unique URI (will be used in the compound formlets) and that the distinction between atomic and compound formlets is wether there is a graph pattern and a form template specified in the formlet.


<form:Formlet rdf:about="http://kmr.nada.kth.se/shame/SDC/formlet#type-DCMIType">
    <form:formModel>type-DCMIType-F.rdf</form:formModel>
    <form:queryModel>type-DCMIType-Q.dl</form:queryModel>
    <form:queryOntology>../../ontologies/DC/dctype.rdf</form:queryOntology>
    <dc:title>
        <rdf:Alt>
            <rdf:li xml:lang="en">Type (DCMITypes)</rdf:li>
        </rdf:Alt>
    </dc:title>
</form:Formlet>

An compounf formlet expressed in RDF/XML

A compound formlet configuration specifies a base formlet and a list of extension formlets that should be added to the base.


<form:Formlet rdf:about="http://kmr.nada.kth.se/shame/SDC/formlet#Simple-profile">
    <dc:title>
        <rdf:Alt>
            <rdf:li xml:lang="en">Simple profile</rdf:li>
        </rdf:Alt>
    </dc:title>
    <form:extensionFormlets>
        <rdf:Seq>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#title"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#description"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#creator"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#contributor"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#publisher"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#subject"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#date"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#format"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#type-DCMIType"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#language"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#identifier"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#coverage"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#relation"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#source"/>
            <rdf:li rdf:resource="http://kmr.nada.kth.se/shame/SDC/formlet#rights"/>
        </rdf:Seq>
    </form:extensionFormlets>
    <form:baseFormlet rdf:resource="http://kmr.nada.kth.se/shame/formlet#base"/>
</form:Formlet>

The references from the compound formlet to the extensions and base formlets are made via identifiers. For this to work all formlets that the compound depends on need to be loaded in advance, this is handled via the ComponentStore class. A simple code example for the neccessary steps are shown below:


DefaultFormletStore store = new DefaultFormletStore(new DefaultFormletFactory());

//  The base formlet is loaded here.
store.loadFormletConfigurations("resources/formlets/formlets.rdf");

//  All extensionformlets needed by the compound as well as the compound itself is loaded here.
store.loadFormletConfigurations("resources/formlets/Simple_Dublin_Core/formlets.rdf");  

//  Now load all neccessary atomic formlets and build the compound
Formlet compound = store.getFormlet("http://kmr.nada.kth.se/shame/SDC/formlet#Simple-profile");

Observe, that when the compound are built both the extension formlets and the base formlet are left untouched so that they can be reused in other compounds later.

Running the example

You can try the example in the SHAME application suite or directly in the CVS. See the Readme-examples.txt for more information about example 4.

The resulting SHAME form editor.