XSD Fu

XSD Fu is a Python application designed to digest OME XML schema and produce an object oriented Java infrastructure to ease work with an XML DOM tree.

Requirements:

NOTE: Genshi  0.5 was released on June 9th 2008. You can either install from source or download a compatible .egg for your system on the Genshi  download page.

Checking out the source

This will get the entire source tree. xsd-fu is in components/xsd-fu

git clone git://git.openmicroscopy.org/ome.git

Running the code generator

If you do have Genshi already installed you can run xsd-fu script with no arguments to examine the syntax:

$ ./xsd-fu 
Missing subcommand!
Usage: ./xsd-fu <subcommand> ...
Executes an OME-XML Schema definition parsing and code generation subcommand.

Available subcommands:
  java_classes
  omexml_metadata
  omero_metadata
  metadata_store
  metadata_retrieve
  metadata_aggregate
  enum_types
  enum_handlers
  doc_gen
  tab_gen
  debug

Report bugs to OME Devel <ome-devel@lists.openmicroscopy.org.uk>

If you do not have Genshi installed you can use a downloaded Python .egg for your platform as follows:

$ export PYTHONPATH=Genshi-0.5-py2.4-linux-i686.egg
$ ./xsd-fu 
Missing subcommand!
Usage: ./xsd-fu <subcommand> ...
Executes an OME-XML Schema definition parsing and code generation subcommand.

Available subcommands:
  java_classes
  omexml_metadata
  omero_metadata
  metadata_store
  metadata_retrieve
  metadata_aggregate
  enum_types
  enum_handlers
  doc_gen
  tab_gen
  debug

Report bugs to OME Devel <ome-devel@lists.openmicroscopy.org.uk>

NOTE: XsdFu is now used for many different types of code generation tasks (mostly targeted at the OMERO and Bio-Formats 4.2.0 releases) as outlined by the subcommand structure above.

Generating the OME-XML Java toolchain

We'll now outline how to generate parts of the OME-XML Java toolchain which are composed of:

  • OME model objects
  • Enumerations for OME model properties
  • Enumeration handlers for regular expression matching of enumeration strings
  • Metadata store and Metadata retrieve interfaces for all OME model properties
  • Various implementations of Metadata store and/or Metadata retrieve interfaces

NOTE: All the below examples assume a full OME-XML specification Subversion checkout.

Java classes for OME model objects

$ ./xsd-fu java_classes -p 'ome.xml.model' -o $LOCI_HOME/components/ome-xml/src/ome/xml/model/ \
	../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd ../specification/Released-Schema/2011-06/V1/ROI.xsd \
	../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd

Enumeration classes for OME model properties

$ ./xsd-fu enum_types -p 'ome.xml.model.enums' -o $LOCI_HOME/components/ome-xml/src/ome/xml/model/enums/ \
	../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd ../specification/Released-Schema/2011-06/V1/ROI.xsd \
	../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd

Enumeration handlers for OME model properties

$ ./xsd-fu enum_handlers -p 'ome.xml.model.enums.handlers' -o $LOCI_HOME/components/ome-xml/src/ome/xml/model/enums/handlers/ \
	../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd ../specification/Released-Schema/2011-06/V1/ROI.xsd \
	../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd

Metadata store and Metadata retrieve interfaces

$ ./xsd-fu metadata_store ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ ./xsd-fu metadata_retrieve ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ cp MetadataStore.java MetadataRetrieve.java $LOCI_HOME/components/bio-formats/src/loci/formats/meta/

OMEXMLMetadataImpl Metadata store and Metadata retrieve implementation

$ ./xsd-fu omexml_metadata ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ ./xsd-fu metadata_aggregate ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ ./xsd-fu dummy_metadata ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ ./xsd-fu filter_metadata ../specification/Released-Schema/2011-06/V1/ome.xsd ../specification/Released-Schema/2011-06/V1/BinaryFile.xsd \
	../specification/Released-Schema/2011-06/V1/ROI.xsd ../specification/Released-Schema/2011-06/V1/SA.xsd ../specification/Released-Schema/2011-06/V1/SPW.xsd
$ cp AggregateMetadata.java DummyMetadata.java FilterMetadata.java $LOCI_HOME/components/bio-formats/src/loci/formats/meta/
$ cp OMEXMLMetadataImpl.java $LOCI_HOME/components/bio-formats/src/loci/formats/ome/

Working with Enumerations and Enumeration Handlers

XsdFu contains a flexible, configuration driven structure to code generate enumeration regular expressions. The configuration file is located off of the xsd-fu/trunk root, in the cfg folder:

Each enumeration has a key-value listing of regular expression to exact enumeration value matches. For example:

...
[Correction]
".*Pl.*Apo.*" = "PlanApo"
".*Pl.*Flu.*" = "PlanFluor"
"^\\s*Vio.*Corr.*" = "VioletCorrected"
".*S.*Flu.*" = "SuperFluor"
".*Neo.*flu.*" = "Neofluar"
".*Flu.*tar.*" = "Fluotar"
".*Fluo.*" = "Fluor"
".*Flua.*" = "Fluar"
"^\\s*Apo.*" = "Apo"
...

Special Thanks

A special thanks goes out to  Dave Kuhlman for his fabulous work on  generateDS which XSD Fu makes heavy use of internally.


See also: EnumTool, http://www.openmicroscopy.org/site/support/file-formats/working-with-ome-xml/developer-information,  http://genshi.edgewall.org/,  http://www.rexx.com/~dkuhlman/generateDS.html

1.3.2-PRO © 2008-2010 agile42 all rights reserved (this page was served in: 0.53895 sec.)

We're Hiring!