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" ); }