Revisiting Xforms

In the next few weeks I will be revisiting the original XForms I created for metadata entry. I started out by adding some styles, so the forms are a bit more user friendly, and am working on resolving some of the issues that I had previously ignored in the original forms.

This week:

I added additional xforms:instances for fields that use a controlled vocabulary. For example we are using several controlled vocabularies for genre (most notably DCMI Type and MARC Genre Type). The list of terms is saved as a separate xml file (genre.xml) that is called as an additional xforms:instance in the xforms:model. The genre instance data populates a select1 menu which populates the genre elements in the metadata instance. New genre terms can be added or edited by a separate xform.

The next step was to deal with the problem of empty repeat elements. In my original forms when the final element in a repeat has been deleted there is no way to insert a new element into the instance. XForms 1.1 has solved this by adding a context attribute. The context attribute is used to select the parent node of the element, when the nodeset is empty, the insert trigger uses the parent node to insert the new element or node. The context attribute is not currently supported in the Firefox extension. I’m exploring several options. This is one (described here also):

When populating my metadata instance I dynamically add blank elements/nodes at the end of the instance for repeating elements to serve as a template for the repeat. In the repeat I use the following:

<xforms:repeat nodeset="item[position()!=last()]" id="repeat-cart">

This omits the empty element I had inserted as template from the xforms:repeat. The following trigger prevents the last visible element from being deleted, the element remains but the data is cleared.

  <xforms:action ev:event="DOMActivate">
     <xforms:delete nodeset="instance('metadata')dc:title[position()!=last()]"
     <xforms:insert nodeset="instance('metadata')dc:title[last()=1]" at="1" position="before"/>

The empty elements get stripped out of the data when it is saved.

I’m also looking for other options to handle the empty xforms:repeat, perhaps using the xforms:bind, or conditional statements.

I have also started submitting the forms via post rather than put, this allows for some processing of the data before it is submitted to the database. Initially I’m using this to strip out the empty elements, but I imagine it will have other uses as well particularly in calculating element and attribute values in for our METS records.

My next step is to start working on some simple MODS forms so that we can make the switch from DC.


3 Responses to “Revisiting Xforms”

  1. Kevin S. Clarke Says:

    Thanks, another very interesting post. I hope you’ll head up a BOF on XForms and library metadata at the upcoming Code4Lib conference. We’d definitely be interested in participating.

  2. wsalesky Says:

    Hi Kevin, I’d be happy to head up a BOF at code4lib.

  3. XForm Repeats « the DIL Says:

    […] In this entry I talk about one method for dealing with empty repeats. Here is the method I ended up […]

Comments are closed.

%d bloggers like this: