Data access object.
Creates new DataSource object. type is one of type constants.
Assigns an OAT.Connection object to this datasource.
Object with various properties, dependant on DataSource Type:
List of wanted fields in fetched data.
Listens for new data records. When new record is available, recordCallback is executed with 2 arguments: record data and record index.
Listens for new data record pages. When new data page (record set) is available, pageCallback is executed with 2 arguments: page data and page index.
Listens for new data file. When new data file is available, fileCallback is executed with 1 argument: file contents.
Listens for empty dataset. When empty dataset arrives, emptyCallback is executed.
Listens for data header. When header arrives, headerCallback is executed with 1 argument: data header.
Advanced through records. recordIndex can be an integer or "-1" or "+1".
var conn = new OAT.Connection(OAT.ConnectionData.TYPE_REST, {url:"myfile.xml"}); var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_REST); ds.connection = conn; ds.options.output = 0; /* fetch result as XML */ ds.options.xpath = 1; /* outputFields are specified as XPATH expressions */ ds.outputFields = ['//result/binding[@name="created"]/node()/text()', '//result/binding[@name="creator"]/node()/text()', '//result/binding[@name="item_title"]/node()/text()', '//result/binding[@name="url"]/node()/text()']; var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);
var conn = new OAT.Connection(OAT.ConnectionData.TYPE_XMLA, {dsn:"DSN=Local_Instance",endpoint:"/XMLA"}); var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_SQL); ds.connection = conn; ds.options.query = "SELECT OrderID, CustomerID, EmployeeID FROM Demo.demo.Orders"; var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);
var connection = new OAT.Connection(OAT.ConnectionData.TYPE_REST,{url:"/sparql/"}); var q = "SELECT ?s, ?p, ?o FROM <http://www.flickr.com/search/?q=rdf+semanticweb&s=rec> WHERE { ?s ?p ?o . }"; var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_SPARQL); ds.outputFields = ['//result/binding[@name="s"]/node()/text()', '//result/binding[@name="p"]/node()/text()', '//result/binding[@name="o"]/node()/text()']; ds.connection = connection; ds.options.query = "query="+encodeURIComponent(q)+"&format=xml"; ds.options.output = 0; /* fetch result as XML */ ds.options.xpath = 1; /* outputFields are specified as XPATH expressions */ var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);