[Project_owners] Converting C code to Javascript/what am I doing wrong?

Michael Vincent mv_van_rantwijk at yahoo.com
Tue Aug 23 17:22:04 EDT 2005


I'm trying to rewrite a perfectly working piece is code in JavaScript, 
because I need something that isn't available, and I don't have a C 
compiler nor do I want to build Mozilla myself simple because I can't 
use it.

The following code fails in RDFCUtils.MakeSeq() but I don't see why:

   var kNC = "rdf:http://home.netscape.com/NC-rdf#";
   var datasource = RDF.GetDataSource("rdf:bookmarks");
   var livemarkResource = RDF.GetAnonymousResource();
   var container = RDFCUtils.MakeSeq(datasource, 
RDF.GetResource(livemarkResource.Value));

   if (aName == undefined || aName == "")
     aName = "NewBookmark"; // localize me!
   datasource.Assert(livemarkResource, RDF.GetResource(kNC + "Name"), 
RDF.GetLiteral(aName), true);
   datasource.Assert(livemarkResource, RDF.GetResource(kNC + "URL"), 
RDF.GetLiteral(aURL), true);
   datasource.Assert(livemarkResource, RDF.GetResource(kNC + "FeedURL"), 
RDF.GetLiteral(aFeedURL), true);

   if (aDescription)
     datasource.Assert(livemarkResource, RDF.GetResource(kNC + 
"Description"), RDF.GetLiteral(aDescription), true);

   var dateLiteral = RDF.GetDateLiteral(Date());
   datasource.Assert(livemarkResource, RDF.GetResource(kNC + 
"BookmarkAddDate"), dateLiteral, true);
   datasource.Assert(livemarkResource, RDF.GetResource(kNC + "type"), 
kNC + "Livemark", true);

It should do exactly the same as:
http://lxr.mozilla.org/aviary101branch/source/browser/components/bookmarks/src/nsBookmarksService.cpp#2845 


So what am I doing wrong?

Thanks,
Michael


More information about the Project_owners mailing list