• Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Start Page
  • Index
  • History
  • Last Change

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:

  • Python 2.4+
  • Genshi 0.5

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

svn co http://svn.openmicroscopy.org.uk/svn/specification/Xml/xsd-fu/trunk xsd-fu

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 
Expecting single ome.xsd file path!
Usage: ./xsd-fu [-n xsd_namespace] [-p package] -o <output_dir> <path/to/ome.xsd>
Generates Java classes from an OME XML Schema definition.

Default package: "ome.xml.r2008"
Default namespace: "xsd:"

Examples:
  ./xsd-fu -n 'xs:' -p ome.xml -o ome/xml schemas/ome.xsd

Report bugs to Chris Allan <callan@blackcat.ca>

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 
Expecting single ome.xsd file path!
Usage: ./xsd-fu [-n xsd_namespace] [-p package] -o <output_dir> <path/to/ome.xsd>
Generates Java classes from an OME XML Schema definition.

Default package: "ome.xml.r2008"
Default namespace: "xsd:"

Examples:
  ./xsd-fu -n 'xs:' -p ome.xml -o ome/xml schemas/ome.xsd

Report bugs to Chris Allan <callan@blackcat.ca>

Generating the OME-XML Java library

To generate the OME-XML node hierarchies for the OME-XML Java library, we use the source:Xml/xsd-fu/trunk/gen.sh script in the XSD Fu source directory.

If you want to generate the same source files yourself, you will need to edit the legacy_ome_path and out_path variables at the top of the script.

Compiling the classes (an example)

During compilation the ome.xml package needs to be available. The easiest way to ensure this is to check out the OME-XML Java library source code from the LOCI Software SVN repository, edit gen.sh's out_path to point to your checked out components/ome-xml/src directory, then compile from the components/ome-xml directory using ant.

Here is a complete workflow for checking out all necessary code, generating source, and compiling:

$ export SVN_ROOT=~/svn

$ export OME_XML_ROOT=$SVN_ROOT/ome-xml
$ mkdir -p $OME_XML_ROOT
$ cd $OME_XML_ROOT
$ svn co http://svn.openmicroscopy.org.uk/svn/specification .
...

$ export OME_LEGACY_ROOT=$SVN_ROOT/ome-legacy
$ mkdir -p $OME_LEGACY_ROOT
$ cd $OME_LEGACY_ROOT
$ svn co http://svn.openmicroscopy.org.uk/svn/ome/trunk/src/xml/schemas .
...

$ export LOCI_ROOT=$SVN_ROOT/loci
$ mkdir -p $LOCI_ROOT
$ cd $LOCI_ROOT
$ svn co https://skyking.microscopy.wisc.edu/svn/java/trunk .
...
$ find components/ome-xml/src/ome/xml/r200* -name '*.java' -exec rm {} \;

$ cd $OME_XML_ROOT/Xml/xsd-fu/trunk
$ sed -i -e 's/^out_path=.*/out_path=$LOCI_ROOT\/components\/ome-xml\/src/' gen.sh
$ sed -i -e 's/^legacy_ome_path=.*/legacy_ome_path=$OME_LEGACY_ROOT\/ome.xsd/' gen.sh
$ head -n 10 gen.sh | tail -n 3
legacy_ome_path=$OME_LEGACY_ROOT/ome.xsd
modern_schemas="2007-06 2008-02"
out_path=$LOCI_ROOT/components/ome-xml/src
$ ./gen.sh
Generating OME 2003-FC source in ome/xml/r2003fc/ome
Generating OME 2007-06 source in ome/xml/r200706/ome
Generating OME 2008-02 source in ome/xml/r200802/ome
Generating SPW 2007-06 source in ome/xml/r200706/spw
Generating SPW 2008-02 source in ome/xml/r200802/spw

$ cd $LOCI_ROOT/components/ome-xml
$ ant

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: DeveloperInfo, http://genshi.edgewall.org/

Download in other formats:

  • Plain Text

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/