[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-rdf
Subject:    Asserting an element into bookmarks tree
From:       Will Sargent <wsargent () atg ! com>
Date:       2000-03-06 0:36:17
[Download RAW message or body]

I'm having trouble getting bookmarks to look right when I assert them
into my datasource.

I have an XUL file which includes my datasource (mostly hacked from
bookmarks.xul)

<tree  id="bookmarksTree" ref="NC:BookmarksRoot" context="contextual"
       datasources="rdf:bookmarks rdf:bookie"
     ...
>

And then I have a bookmark called bookie://localhost/ which my
datasource understands and uses to call up a stream listener on
localhost.  The stream listener does some basic parsing of RDF, and uses
the data returned to assert into the inner memory datasource.

My problem is that although I can get the bookmarks to be parsed in, and
I can even get the tree to recognise that bookie://localhost/ has a
child folder (which should be called Bookmarks for Will Sargent), I
can't get it to display a name.  This seems pretty strange considering
I'm basically using code from RDFFTPDatasource.


[Image]

Here's the appropriate bits of code.


   // Insert the title.
   title.Trim(" ");
   if (title.Length() > 0)
   {
    const PRUnichar *name = title.GetUnicode();
    if (nsnull != name)
    {
     nsCOMPtr<nsIRDFLiteral> nameLiteral;
     if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(name,
getter_AddRefs(nameLiteral))))
     {
      mDataSource->Assert(newNode, kNC_Name, nameLiteral, PR_TRUE);
     }
#ifdef DEBUG
     // XXX memory leak in creating new cstring?
     printf("inserting bookie node [%s] %s\n", nodeType.ToNewCString(),
title.ToNewCString());
#endif
    }
   }


   // Insert the node type, bookmark, folder or seperator.
   if (nodeType.Length() > 0)
   {
    theStart = nodeType.Find("folder", PR_TRUE);
    if (theStart == 0)
    {
     mDataSource->Assert(newNode, kRDF_type, kBP_BookieObject, PR_TRUE);

     //mDataSource->Assert(newNode, kRDF_type, kNC_Folder, PR_TRUE);
    }

    theStart = nodeType.Find("bookmark", PR_TRUE);
    if (theStart == 0)
    {
     //mDataSource->Assert(newNode, kRDF_type, kBP_BookieObject,
PR_TRUE);
     mDataSource->Assert(newNode, kRDF_type, kNC_Bookmark, PR_TRUE);
    }

    theStart = nodeType.Find("seperator", PR_TRUE);
    if (theStart == 0)
    {
     //mDataSource->Assert(newNode, kRDF_type, kBP_BookieObject,
PR_TRUE);
     mDataSource->Assert(newNode, kRDF_type, kNC_BookmarkSeparator,
PR_TRUE);
    }

   rv = mDataSource->Assert(mParent, kNC_Child, newNode, PR_TRUE);

I'm asserting kNC_Child, kNC_Name, and kRDF_type.  Is there anything
else I need to get it to work?

Will.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic