XML « Quædam cuiusdam
MODS Editor at last
Saturday 16 February 2008 @ 9:30 am

The MODS Editor has occupied my development time lately, and has reached a state approximating completion. I’ve posted about it here and here in the distant past. It is built with the Cocoon Forms framework, and provides full editing functionality in the browser. It now has a localization mechanism, which allows you to modify the form for a particular project by means of a simple configuration file. This will be important in my environment, where new projects pop up from time to time with unique requirements for a convenient metadata creation form. The MODS Editor localization feature will allow me to keep the main form definition untouched; the localization configuration is used to generate an XSL stylesheet on the fly, which is applied on the fly to the form definition files. Currently it allows you to remove elements and fields that you don’t want (which is all you need to customize the form, since it already contain all MODS elements and fields except mods:extension), and to add selection lists to particular fields. In the future I intend to add the ability to provide validation rules, control the layout of the form, and so on.

You can try it out at the MODS Editor demo; the code is available there under a GPL 3.0 license. And there is reasonably complete documentation.

There’s more and more competition in this space in the FLOSS world: Winona Salesky (The DIL) has done great things with XForms, and the forthcoming Metadata Toolkit build by Mark Jordan and team for the Alouette Canada project on the basis of the Qubit toolkit will be tremendous. So if you’re not already a Cocoon user, this may not be the shortest available route to a full-featured MODS editor for your project. But if you like the idea of starting with a full MODS form and easily trimming out the bits you don’t need for each project on your plate, give it a look.

Comments (2) - Posted in XML by  



Why Cocoon won’t build
Friday 13 July 2007 @ 1:02 pm

I will not use Solaris tar to unpack Cocoon source packages

  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages
  • I will not use Solaris tar to unpack Cocoon source packages

If you get zillions of “cannot find symbol” errors when building Cocoon, it’s because tar truncated some long paths, including src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java, which lost the “va” in “.java”, and so it wasn’t compiled.

Use GNU tar and all is well. Just like the last time you tried to build a new Cocoon release on a Solaris box, the memory of which you have repressed like the idiot I am. (Sorry, did I say that out loud?)

Comments (2) - Posted in XML by  



Cocoon Plumber
Sunday 4 February 2007 @ 5:22 pm

Cocoon‘s pipeline-driven service style is ideal for serving structured data on the web. It reduces every data problem to an XML issue, and every processing and viewing problem to an XSLT problem. The same tools can be brought to bear on all aspects of the service; as your skills deepen, the benefits are exponential.

As a Cocoon project becomes more complex, though, it’s helpful to have tools that let you see what’s going on inside the pipelines. Cocoon provides views, which allow you to see the output of each step in the pipeline, and profiling, which adds timings. Getting at these can be a little tedious when working intensively, so it would be nice to have a menu that shows you the pipeline that generated the current page and lets you see the views, the components, and the timings easily.

This project, called “Cocoon Plumber”, provides such a menu in the form of a Firefox sidebar. It has two components: a Firefox extension that generates the sidebar, and a Cocoon subproject that can be dropped into any existing Cocoon sitemap to provide the information to populate the sidebar.
Cocoon Plumber Screenshot

Installation

Download and unzip the code. To try out the demo, add the cpdemo directory to the mount-table of a recent Cocoon installation, like this:

<mount uri-prefix="cpdemo" src= "file://C:/Documents and Settings/Peter/My Documents/projects/cocoon-plumber/cpdemo/"/>

Install the Firefox extension cocoonplumber.xpi in the usual way. Restart Firefox. If your Cocoon isn’t running at http://localhost:8888/, open the options menu for the Cocoon-Plumber extension and change the base url as needed.

Now visit http://localhost:8888/cpdemo/blah1/blah2/test.html. The page you see is generated by a very simple pipeline: it starts with a simple xml file containing a “step” element, and a couple of stylesheets add two more steps, and then a final stylesheet turns it into html. To see all this, hit Ctrl-Shift-C to open the sidebar. You can inspect the xml and xsl files by clicking the links in the src attributes, and you can view the intermediate cocoon-views of the output of each step by clicking the label link.

Plumber is easy to add to an existing Cocoon project. Just copy the “plumber” directory from cpdemo into the base directory of the project (where the project sitemap.xmap is found). Add this pipeline to the project sitemap, at the top of the <map:pipelines> element:

<map:pipeline>
  <map:match pattern="plumber/**">
    <map:mount check-reload="yes" uri-prefix="plumber" src="plumber/sitemap.xmap"/>
  </map:match>
  <map:match pattern="profile.xml">
    <map:generate type="profiler"/>
    <map:serialize type="xml"/>
  </map:match>
</map:pipeline>

The second map:match is optional, and depends on your having configured profiling in your project. If profiling is not available, plumber will still work; it will simply not display timings.

Finally, you need to activate the CInclude and Source-Writing transformers, if they aren’t already used in your project:

<map:transformers default="xslt">
  <map:transformer name="cinclude" src= "org.apache.cocoon.transformation.CIncludeTransformer"/>
  <map:transformer name="write-source" src= "org.apache.cocoon.transformation.SourceWritingTransformer"/>
</map:transformers>

How it works

Firefox component:

The Firefox extension needs to be given the base url of the Cocoon project. With that, it can populate the sidebar with a menu appropriate to any page generated by the Cocoon project. The sidebar will contain a view of the pipeline, with all the stylesheets linked to allow the user to view them. The component labels are also linked to allow you to see the current page through that view. All sidebar links cause new tabs to open.

Cocoon component:

The sidebar gets its data from a sub-sitemap that generates HTML from the main sitemap, so that it can present a view of the current pipeline. This involves using the sitemap.xmap as the source xml in the generator; the but the first problem is to identify the pipeline that is generating the current page. Since pipelines can use all sorts of different matchers, there’s no easy way to do this. I owe to Art Rhyno an ingenious solution: we apply a stylesheet to the base sitemap.xmap to produce a new plumber.xmap, which “hollows out” each pipeline and applies explicit ids. Since the plumber.xmap uses the same matchers as the base sitemap.xmap, it reliable identifies the pipeline that a given page is using. To deploy this new sitemap is a two-step process: we mount the plumber sub-project’s sitemap as a sub-sitemap, and it in turn generates the plumber sitemap from the base sitemap and mounts it to serve sidebar requests.

This allows the Firefox extension to derive the plumber url from any given url from the base project: if (as in the supplied demo) the base project url is

http://localhost:8888/cpdemo/test.html

then the plumber url will be

http://localhost:8888/cpdemo/plumber/sitemap/test.html

The “plumber” level points to the plumber sub-project sitemap, and the “sitemap” element points to the generated plumber sitemap.

To do

There’s plenty that could usefully be done to improve Cocoon Plumber. I’ve taken it as far as I have time to for the moment, but I’d welcome fixes or enhancements from any source.

  • the sidebar keeps showing the hourglass cursor even after the page has fully loaded; I can’t figure out why
  • mapping the profiling data to the components of the pipeline isn’t entirely reliable



Older Posts »