Next Previous Up Contents
Next: TABLE element output
Up: Writing VOTables
Previous: Generic table output

6.3.2 Single VOTable output

The simplest way to output a table in VOTable format is to use a VOTableWriter, which will output a VOTable document with the simplest structure capable of holding a TABLE element, namely:

    <VOTABLE version='1.0'>
      <RESOURCE>
        <TABLE>
          <!-- .. FIELD elements here -->
          <DATA>
            <!-- table data here -->
          </DATA>
        </TABLE>
      </RESOURCE>
    </VOTABLE>
The writer can be configured/constructed to write its output in any of the formats described in section 6.1 (TABLEDATA, inline FITS etc) by using its DataFormat and inline attributes. In the case of streamed output which is not inline, the streamed (BINARY or FITS) data will be written to a new file with a name similar to that of the main XML output file.

Assuming that you already have your StarTable to output, here is how you could write it out in all the possible formats:

    void outputAllFormats( StarTable table ) throws IOException {
        VOTableWriter voWriter = new VOTableWriter( DataFormat.TABLEDATA, true );
        voWriter.writeStarTable( table, "tabledata-inline.xml" );

        voWriter.setDataFormat( DataFormat.FITS );
        voWriter.writeStarTable( table, "fits-inline.xml" );

        voWriter.setDataFormat( DataFormat.BINARY );
        voWriter.writeStarTable( table, "binary-inline.xml" );

        voWriter.setInline( false );
        voWriter.setDataFormat( DataFormat.FITS );
        voWriter.writeStarTable( table, "fits-href.xml" );

        voWriter.setDataFormat( DataFormat.BINARY );
        voWriter.writeStarTable( table, "binary-href.xml" );
    }


Next Previous Up Contents
Next: TABLE element output
Up: Writing VOTables
Previous: Generic table output

STIL - Starlink Tables Infrastructure Library
Starlink User Note 252
STIL web page: http://www.starlink.ac.uk/stil/
Author email: m.b.taylor@bristol.ac.uk
Starlink: http://www.starlink.ac.uk/