problem with the first getSources call

"Mariano Cuenze" <[email protected]> Fri, 19 Dec 2008 17:37:46 -0300
Newsgroups gmane.comp.mozilla.devel.rdf
Message-ID <[email protected]>
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