when executing the following code firebug tells me: values[this.geo.value] is undefined what is the problem?
$.get('./RDFexamples/tin00089_test2.rdf', null, function (rdfXml) {
var rdf, json = {};
var values = new Array();
rdf = $.rdf()
.load(rdfXml)
.prefix('', '')
.prefix('qb', '')
.prefix('rdf', '')
.prefix('dcterms', '/')
.prefix('sdmx-measure', '')
.where('?observation a qb:Observation')
.where('?observation dcterms:date ?date')
.where('?observation sdmx-measure:obsValue ?measure')
.where('?observation :geo ?geo')
.each(function () {
values[this.geo.value].push(this.measure.value);
//alert(this.date.value)
//alert(this.measure.value)
//alert(this.geo.value)
}
);
alert(values);
});
when executing the following code firebug tells me: values[this.geo.value] is undefined what is the problem?
$.get('./RDFexamples/tin00089_test2.rdf', null, function (rdfXml) {
var rdf, json = {};
var values = new Array();
rdf = $.rdf()
.load(rdfXml)
.prefix('', 'http://ontologycentral./2009/01/eurostat/ns#')
.prefix('qb', 'http://purl/linked-data/cube#')
.prefix('rdf', 'http://www.w3/1999/02/22-rdf-syntax-ns#')
.prefix('dcterms', 'http://purl/dc/terms/')
.prefix('sdmx-measure', 'http://purl/linked-data/sdmx/2009/measure#')
.where('?observation a qb:Observation')
.where('?observation dcterms:date ?date')
.where('?observation sdmx-measure:obsValue ?measure')
.where('?observation :geo ?geo')
.each(function () {
values[this.geo.value].push(this.measure.value);
//alert(this.date.value)
//alert(this.measure.value)
//alert(this.geo.value)
}
);
alert(values);
});
Share
Improve this question
edited Jun 16, 2011 at 9:05
Gaurav Saxena
1571 silver badge6 bronze badges
asked Jun 16, 2011 at 8:55
betabeta
5,70616 gold badges63 silver badges113 bronze badges
2 Answers
Reset to default 3values[this.geo.value] is never initialized so you can't do .push because values[this.geo.value] is undefined, you first need to create an array in values[this.geo.value] before you can push things into it.
Pseudo-code example
if values[this.geo.value] == undefined {
values[this.geo.value] = []
}
values[this.geo.value].push(...)
push
is a method of the Array object itself - you are calling it on a value within the Array (which has probably not been set, hence 'undefined'). It's unclear what this.geo.value
is, but assuming its the index of the array item you are trying to set, your options are:
values.push(this.measure.value);
or
values[this.geo.value] = this.measure.value;