[Project_owners] Problems with nsIRDFDataSource.AppendElement()

Alex Eng aeng at intergate.ca
Thu Jun 9 00:46:48 EDT 2005

In my code, I'm adding a new RDF node to an <RDF:Seq> using the 
AppendElement() method of the nsIRDFDataSource interface, as per the 
following code excerpt:

   var rdfSvc = 
   var rdfContainer = 
   var dataSource;

   // Get data source, call rdfContainer.Init(), etc....

   var newNode = rdfSvc.GetAnonymousResource();
   var prop = rdfSvc.GetResource("http://...#name");
   var target = rdfSvc.GetLiteral("Joel User");

   try {
     dataSource.Assert(newNode, prop, target, true);
   } catch (e) {
   // ...

It appears that the line


seems to do nothing - i.e., no new node is added to the <RDF:Seq> 
container.  Substituting the call to AppendElement() with 
InsertElementAt(), i.e.,

    rdfContainer.InsertElementAt(newNode, 1, true);

won't work, as InsertElementAt() will return NS_ERROR_FAILURE.

Is there something that I'm doing wrong here?  How can I get 
AppendElement() to do what it's supposed to do?  Thanks.

More information about the Project_owners mailing list