The simplest way to read a VOTable is to use
the generic table reading method described
in section 3.2, in which you just submit the URL or
filename of a document to a
StarTableFactory
,
and get back a StarTable
object.
If you're after one of several TABLE elements in a document,
you can specify this by giving its number as the URL's
fragment ID (the bit after the '#' sign).
The following code would give you StarTable
s
read from the first and fourth TABLE elements in the file "tabledoc.xml":
StarTableFactory reader = new StarTableFactory(); StarTable tableA = reader.makeStarTable( "tabledoc.xml" ); StarTable tableB = reader.makeStarTable( "tabledoc.xml#3" );
If you know it's going to be a VOTable (rather than, e.g., a FITS table)
you could use a VOTableBuilder
instead of a
StarTableFactory
, which works in much
the same way, though you need to supply a
DataSource
rather than a URL. In most cases there is no particular advantage to this.
In either case, all the data and metadata from the TABLE in the
VOTable document are available from the resulting StarTable
object,
as table parameters, columnInfos or the data itself.
If you are just trying to extract the data and metadata from a
single TABLE element somewhere in a VOTable document, either of
these procedures should be fine.
The parameters
of the table which is obtained are taken from PARAM and INFO elements.
Since these cannot occur within a TABLE element itself, any PARAM or
INFO in the RESOURCE element which is the parent of a given TABLE is
taken to apply to that table. The value of these can be obtained using the
getParameters
method.