The simplest way to read a VOTable is to use
the generic table reading method described in Section 3.2
(or Section 3.3 for streaming)
in which you just submit the location 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, or the third argument of
streamStarTable
for streaming).
The following code would give you StarTable
s
read from the first and fourth TABLE elements in the file "tabledoc.xml":
StarTableFactory factory = new StarTableFactory(); StarTable tableA = factory.makeStarTable( "tabledoc.xml", "votable" ); StarTable tableB = factory.makeStarTable( "tabledoc.xml#3", "votable" );or equivalently
VOTableBuilder votBuilder = new VOTableBuilder(); boolean wantRandom = false; StoragePolicy policy = StoragePolicy.getDefaultPolicy(); StarTable tableA = votBuilder.makeStarTable( DataSource.makeDataSource( "tabledoc.xml" ), wantRandom, policy ); StarTable tableB = votBuilder.makeStarTable( DataSource.makeDataSource( "tabledoc.xml#3" ), wantRandom, policy );Note this will perform two separate parses of the document, one for each table built.
All the data and metadata from the TABLE in the
VOTable document are available from the resulting
StarTable
objects,
as table parameters, ColumnInfo
s
or the data themselves.
If you are just trying to extract the data and metadata from a
single TABLE element somewhere in a VOTable document, this
procedure is probably all you need.