Hi, all. I have problem to get my in-memory datasource working. I would like to use the in-memory datasource to create a menu contains folders and each folder contains some folders, just like the bookmarks menu. I am trying to use "ID" and "about" to achieve what I want to do e.g. ID="1" points to about="#1" (please see below), however, I am only able to show a folder/ folders on the top level and nothing inside those folders. Can anyone give me some advice please? Thanks
Raymond <!-- the RDF structure I want to achieve in the memory datasource --> <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:fly="http:/www.abc.com/fly-rdf#"> <rdf:Description about="urn:root"> <fly:rows> <rdf:Seq> <rdf:li> <rdf:Description ID="1" fly:folder="Demo"/> </rdf:li> </rdf:Seq> </fly:rows> </rdf:Description> <rdf:Description about="#1"> <fly:rows> <rdf:Seq> <rdf:li> <rdf:Description ID="1_1" fly:folder="Folder 1.1" /> </rdf:li> </rdf:Seq> </fly:rows> </rdf:Description> <!-- End: the RDF structure I want get --> <?xml version="1.0"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <menubar> <menu label="Menu"> <menupopup datasources="rdf:null" ref="urn:root" onpopupshowing="call the executeRDFQuery()"> <template> <!-- RULE 1: Menu contains folder --> <rule> <conditions> <content uri="?uri"/> <triple subject="?uri" predicate="http:/www.abc.com/fly-rdf#rows" object="?rows"/> <member container="?rows" child="?row"/> <triple subject="?row" predicate="http:/www.abc.com/fly-rdf#folder" object="?folder"/> </conditions> <action> <menu label="?folder" uri="?row"> <menupopup uri="?row"/> </menu> </action> </rule> </template> </menupopup> </menu> </menubar> </window> /******** js file *************/ var RDFC = '@mozilla.org/rdf/container;1'; RDFC = Components.classes[RDFC].createInstance(); RDFC = RDFC.QueryInterface(Components.interfaces.nsIRDFContainer); var RDFCUtils = '@mozilla.org/rdf/container-utils;1'; RDFCUtils = Components.classes[RDFCUtils].getService(); RDFCUtils = RDFCUtils.QueryInterface(Components.interfaces.nsIRDFContainerUtils); var RDF = '@mozilla.org/rdf/rdf-service;1'; RDF = Components.classes[RDF].getService(); RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService); Test.prototype.getLevelZero = function() { var dsource = Components.classes['@mozilla.org/rdf/datasource;1?name=in-memory-datasource' ].createInstance (Components.interfaces.nsIRDFDataSource); var rootSubject = RDF.GetResource('urn:root'); var rowsPredicate = this.getRDFResource('rows'); var rowsResource = RDF.GetAnonymousResource(); var rowsList = RDFCUtils.MakeSeq(dsource, rowsResource); dsource.Assert(rootSubject, rowsPredicate, rowsResource, true); var row = RDF.GetAnonymousResource(); /******* add the ID in here ***********/ dsource.Assert(row, RDF.GetResource('ID'), RDF.GetLiteral("1"), true); /**************************************/ var predicate = "http:/www.abc.com/fly-rdf#folder"; var value = "Demo"; dsource.Assert(row, predicate, RDF.GetLiteral(value), true); rowsList.AppendElement(row); return dsource; } Test.prototype.getLevelOne = function(dsource) { var subject = RDF.GetResource("#1"); var rowsPredicate = this.getRDFResource('rows'); var rowsResource = RDF.GetAnonymousResource(); var rowsList = RDFCUtils.MakeSeq(dsource, rowsResource); dsource.Assert(subject, rowsPredicate, rowsResource, true); var row = RDF.GetAnonymousResource(); /******* add the ID in here ***********/ dsource.Assert(row, RDF.GetResource('ID'), RDF.GetLiteral("1_1"), true); /**************************************/ var predicate = "http:/www.abc.com/fly-rdf#folder"; var value = "Folder 1.1"; dsource.Assert(row, predicate, RDF.GetLiteral(value), true); rowsList.AppendElement(row); return dsource; } Test.prototype.executeRDFQuery = function() { var dsource = this.getLevelZero(); dsource = this.getLevelOne(dsource); return dsource; } /********End: js file *************/ _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
