VOTables

Introduction and Background

VOTable is an XML-based format for representing astronomical catalogs (i.e. tabular data) in a uniform manner across all VO software and services. XML allows the use of industry standard tools and software introduced earlier, but more importantly allows us to capture the rich set of metadata associated with the data and/or columns of the table.

The immediate ancestors of the format are Astrores developed at CDS and the eXtensible Scientific Interchange Language (XSIL). several of the NVOSS faculty were heavily involved in the definition of the format and VOTable was one of the first standards developed by the VO and adopted by all IVOA partners.

The VOTable Document Format

The formal specification of VOTables is maintained at the IVOA site http://www.ivoa.net/Documents/latest/VOT.html and we'll only review the highlights of the format here. Key features of VOTables include:

Sample VOTable

<?xml version="1.0"?>
<VOTABLE version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/VOTable/v1.1">
  <COOSYS ID="J2000" equinox="J2000." epoch="J2000." system="eq_FK5"/>
  <RESOURCE name="myFavouriteGalaxies">
    <TABLE name="results">
      <DESCRIPTION>Velocities and Distance estimations</DESCRIPTION>
      <PARAM name="Telescope" datatype="float" ucd="phys.size;instr.tel"
        unit="m" value="3.6"/>
      <FIELD name="RA" ucd="pos.eq.ra;meta.main" ref="J2000"
        datatype="float" width="6" precision="2" unit="deg"/>
      <FIELD name="Dec" ucd="pos.eq.dec;meta.main" ref="J2000"
        datatype="float" width="6" precision="2" unit="deg"/>
      <DATA>
        <TABLEDATA>
          <TR><TD>010.68</TD><TD>+41.27</TD></TR>
          <TR><TD>287.43</TD><TD>-63.85</TD></TR>
        </TABLEDATA>
      </DATA>
    </TABLE>
  </RESOURCE>
</VOTABLE>

Looking at the specification and the example above we find that the data model for a VOTable is composed of:

To help take some of the mystery out of a VOTable, let's break down the sample in places and explain each element in more detail.


VOTABLE

This is the root element of the XML document tree and there can therefore be only one occurance in a file. The children of a VOTABLE will typically include as part of the metadata:

Additionally, and the part that we're usually really interested in, one or more:


TABLE

A TABLE may contain descriptive or other metadata elements such as

Data itself begins with the <DATA> tag in table cells in the same order as the <FIELD> definitions. All records MUST have the same format, empty cells are simply denoted with an empty tag.


FIELD

A FIELD is a description of a table column that may contain additional descriptive elements such as LINK, VALUES or DESCRIPTION. Attributes are used to specify


PARAM

A PARAM is like a FIELD but keeps a constant value. It has the same set of attributes as FIELD and can be thought of as a global definition that applies to the entire RESOURCE.


DATA

The DATA element is unique in a TABLE, however a RESOURCE may contain multiple TABLEs. There are three possible formats for the data:

FITS and BINARY formats must contain a <STREAM> element, for instance

<TABLE> 
  <FIELD  ....>
  <DATA>
    <FITS extnum="2">
      <STREAM encoding="gzip" href="ftp://archive.nvo.org/myfile.fits.gz"/>
    </FITS>
  </DATA> 
</TABLE> 

GROUP

The GROUP element is a relatively new feature meant to allow the logical association of FIELD and PARAM metadata elements. As you can see from the example this form of association is not unusual in astronomical tables, however the GROUP element is not supported by all current parsers/writers (STIL java library, C++ Parsers from VO-India appear to be the only ones)


<TABLE name="Nutation and Abberation"">
  <FIELD name="Date">
  <GROUP name="Nutation">
    <FIELD name="Long">
    <FIELD name="Obl">
  </GROUP>
  <GROUP name="Abberation">
    <GROUP name="Equinox 1950">
       <FIELD name="C_1950">
       <FIELD name="D_1950">
    </GROUP>
    <GROUP name="Equinox 1955">
       <FIELD name="C_1955">
       <FIELD name="D_1955">
    </GROUP>
  </GROUP>
</TABLE>
Nutation and Abberation
Date Nutation Abberation
in
Long.
in
Obl.
19501955
CD CD
Oct 1 +16 231+02 23318 6392 56918 6362 594
2 +16 231+02 23318 6392 56918 6362 594
3 +16 231+02 23318 6392 56918 6362 594
4 +16 231+02 23318 6392 56918 6362 594
5 +16 231+02 23318 6392 56918 6362 594


Reading VOTable Example

In the $NVOSS_HOME/java/dev/readvotable directory you'll find a sample program using the VOTwrap interface for parsing the file. Below we show a slightly modified version of that same task to be used as a basis for discussion during the presentation.

package readvotable;
import edu.jhu.pha.ivoa.*;
import java.io.*;
import java.text.*;

class ReadVotable {
 public static void main(String[] args) throws Exception{
   int ind =0; 
   if (args.length == 0 ) {
	System.out.println("You need to suply the filename of a votable ");
	System.exit(1);
   }
   readVot(args[0]); 
 }

 public static void readVot(String fname) throws Exception{
	InputStream is = new FileInputStream(fname);	
	VOTWrap.VOTable vot = VOTWrap.createVOTable(is);

	VOTWrap.Resource res = vot.getResource(0);
	VOTWrap.Table tab =  res.getTable(0);
	int fcount = tab.getFieldCount();
	int rcount = tab.getTableData().getTRCount();

 	for (int f=0; f < fcount; f++) {
	   VOTWrap.Field field = tab.getField(f);
	   System.out.print (field.getName()+":"+field.getUCD()+" ");
	}

	System.out.println();
	System.out.println (" There are "+ fcount +" fields on " + rcount + " rows:");

 	for (int r=0; r < rcount; r++) {
	  VOTWrap.TR row = tab.getTableData().getTR(r);
 	  for (int f=0; f < fcount; f++) {
	     VOTWrap.TD td = row.getTD(f);
	     System.out.print (td.getPCDATA()+"   ");
	  }
	  System.out.println();
	}
 }
}

Exercise

Beginning with the above program or the original code, modify the task to read a VOTable and output one or more HTML tables (i.e. only the data or separate tables for the metadata and tabular data). The java print() or println() would be used to write out the additional markup.



XSLT Transformation Example

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/VOTABLE">

<html><body>
 <xsl:for-each select="RESOURCE/TABLE">
  <table border="1">
  <tr> <xsl:for-each select="FIELD">
     <td><b><xsl:value-of select="@name" /> </b></td>
  </xsl:for-each> </tr>

  <xsl:for-each select="DATA/TABLEDATA/TR">
       <tr>
        <xsl:for-each select="TD">
          <td width="120"><xsl:value-of select="." /></td>
        </xsl:for-each>
       </tr>
  </xsl:for-each>
  </table>
 </xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
produces...
RADec
010.68+41.27
287.43-63.85
Exercise:
  • Cut and paste the sample VOTable above and using your favorite editor save to a file called e.g. sample.xml
  • Cut and paste the sample XSLT stylesheet to the left and save to a file called e.g. sample.xsl
  • Apply the stylesheet to the VOTable to produce the HTML table:
  • (on Unix):
    • % xsltproc sample.xsl sample.xml
Homework:
  • Modify the stylesheet to extract the PARAM values into a separate table before printing out the data table. See this file for a modified XSLT solution, and this file for the results, if you get stuck.


Examining VOTables

The earlier introduction to VO applications mentioned a number of tools that make use of VOTables for image overlays (Aladin), plotting (VOPlot) or interaction (TOPCAT). These tools are all included in the NVOSS software distribution and you should experiment with these.



Command-line VOTable Tools

In developing your own applications or services you may or may not need to ever actually parse or create a VOTable yourself. In doing science with VO data and your own legacy code, it may be more convenient to simply convert or manipulate a VOTable into some form that is easier to use. An excellent set of tools to do this is the STILTS command-line tools available from Starlink.

STILTS currently consists of the following commands:

tcopy - Table format converter
Converts tables between formats.
tpipe - Generic table pipeline processing utility
Powerful command providing row selection, sorting, column rearrangement, algebraic data manipulation, statistical calculations, metadata display, format conversion, etc.
votcopy - VOTable encoding translator
Copies VOTable data leaving the structure intact but changing the data encoding between TABLEDATA, BINARY and FITS.
votlint - VOTable validity checker
Checks whether a VOTable document conforms to the standard, reporting on many aspects beyond simple conformance to the schema/DTD.

The NVOSS software distribution contains the jar file containing a programatic interface to each of these procedures, the command-line tools may be installed by downloading from the STILTS link above


VOTable Resources

Parsers

Name Description Link
Java VOTWrap read $NVOSS_HOME/java/dev/ivoaclient/src/ivoa
JAVOT read http://www.us-vo.org/VOTable/JAVOT/
SAVOT read/write/edit http://cdsweb.u-strasbg.fr/devcorner.gml
STIL (Starlink Tables Infrastructure Library) read/write/edit http://www.starlink.ac.uk/stil/
VOTable Java Parser based on XML Schema read/write http://spider.ipac.caltech.edu/staff/jchavez/public/votable_parser.html
VOTable Java Streaming Writer write http://vo.iucaa.ernet.in/~voi/votableStreamWriter.htm
C++ C++ Parser read http://vo.iucaa.ernet.in/~voi/cplusparser.htm
Perl VOTable Perl Modules read/write http://heasarc.gsfc.nasa.gov/classx/votable/
VOTable::DOM format/print http://monet.ncsa.uiuc.edu/~rplante/VO/VOTable-DOM.pm

Applications

Name Description Link
Aladin Interactive software sky atlas to visualize digitized images, to superimpose entries from astronomical catalogs http://aladin.u-strasbg.fr/
conVOT For converting ASCII or FITS tables to VOTable format http://vo.iucaa.ernet.in/~voi/conVOT.htm
Mirage Data visualization tool and exploratory analysis http://www.bell-labs.com/project/mirage/
STILTS Command-line votable format conversion and processing http://www.star.bris.ac.uk/~mbt/stilts/
TOPCAT Table visualization and editing http://www.starlink.ac.uk/topcat/
Treeview Viewer for hierarchical structures of astronomical data http://www.starlink.ac.uk/treeview/
VOPlot Visualization tool for VOTable data http://vo.iucaa.ernet.in/~voi/voplot.htm
VotFilter an XML filter for OpenOffice Calc to read and write VOTable files http://services.china-vo.org/vofilter/
RVS Server-side display of n-dimensional astronomical images http://www.atnf.csiro.au/vo/rvs/