problem with the first getSources call

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with the first getSources call

Mariano Cuenze
Hi.

I am working for my first time with an RDF database. After loading the
rdf databae from a file, I do some consecutives GetSources calls with
the neccesary code to proccess every one. For some reason, allways,
the first call fails. If I exchange the GetSources calls, the new
first one will fail too. Is there something to be done between the
loading and the "querying" to be sure that this will not happen again?

Thank you for the help.

PD: the code that i am using is:

//form http://trac.assembla.com/bixo/browser/trunk/app/chrome/content/utils/rdf-utils.js

function loadRDF ( uri )
{
  var RDF = Components . classes [ "@mozilla.org/rdf/rdf-service;1" ]
. getService ( Components . interfaces . nsIRDFService );
  return RDF . GetDataSource ( uri );
}

function getRdfObjs ( mainDB , aPredicate, aKind,  aValue )
{
  var RDF = Components . classes [ "@mozilla.org/rdf/rdf-service;1" ]
. getService ( Components . interfaces . nsIRDFService );
  var kinds = { toResource:"GetResource" , toLiteral:"GetLiteral" };

  var _enum = mainDB . GetSources ( RDF . GetResource ( aPredicate ) ,
RDF [ kinds [ aKind ] ] ( aValue ) , true);

  str="";
  while ( _enum . hasMoreElements ( ) )
  {
    var obj = _enum . getNext ( );
    obj = obj . QueryInterface ( Components . interfaces . nsIRDFResource);
    str += obj . Value + " ";
  }
  alert ("~"+str+"~");
}

//from http://trac.assembla.com/bixo/browser/trunk/app/chrome/content/main/main.js
mainDB = loadRDF ( "chrome://bixo/content/db/mainBase.rdf" );
getRdfObjs ( mainDB ,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "toResource",
"http://www.phiuba.com.ar/bixo/elements/1.0/Plan");
  getRdfObjs ( mainDB ,
"http://www.phiuba.com.ar/bixo/elements/1.0/depto", "toResource",
"http://www.fi.uba.ar/deptos/62");

//and the db is at:
http://trac.assembla.com/bixo/browser/trunk/app/chrome/content/db/mainBase.rdf

--
Mariano
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: problem with the first getSources call

Neil Deakin
Mariano Cuenze wrote:

> Hi.
>
> I am working for my first time with an RDF database. After loading the
> rdf databae from a file, I do some consecutives GetSources calls with
> the neccesary code to proccess every one. For some reason, allways,
> the first call fails. If I exchange the GetSources calls, the new
> first one will fail too. Is there something to be done between the
> loading and the "querying" to be sure that this will not happen again?
>
> Thank you for the help.
>
> PD: the code that i am using is:

Are you waiting for the rdf datasource to load? You might want to use
GetDataSourceBlocking or add a listener to wait for it to load.
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf