How do I use a tree with RDF stored on a remote server?
You can use trees with remote RDF in the same manner as with non-remote RDF.
Most people who encounter a problem can usually see the tree column headers, but the body of the tree is empty. There are several things to try to resolve this issue.
First ensure that the datasources attribute is set to the correct URL. It should either be a relative URL, which will be resolved relative to the XUL file, or an absolute path on the same server as the XUL file. RDF cannot be loaded from a different host than the XUL file (this is also the case with most types of files.) XUL installed as chrome does not have restrictions on where the RDF can be loaded from.
Ensure that the RDF file is being sent with the correct content type. Mozilla accepts 'text/rdf', 'text/xml' or 'application/xml'. Mozilla does not currently support RDF sent as 'application/rdf+xml'. Try loading the RDF file by typing it's URL into the Mozilla address bar. If the browser displays the content as XML, then the server is sending the content correctly. You can look at the Page Info dialog to be sure.
Entering the URL directly into the address bar is also useful to ensure that the RDF file does not contain errors. It should be obvious that there is an error in the RDF in this case.
You might also try renaming the RDF file so that it has an .xml extension, and updating your XUL file accordingly.
Mozilla caches chrome RDF data until either the datasource is not being used, Mozilla is restarted or you call the datasource's Refresh function. Thus, you may find that you will need to restart Mozilla in order to see if changes you have made have any effect. This probably won't be the case for non-chrome RDF as it should be unloaded when the XUL is unloaded.
Ensure also that your tree element is flexible. This can be done adding a flex attribute to the tree. You might also need to set a width and height for the tree.
This following example shows how remote RDF works. (RDF file)View
<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="treeRDF" title="RDF Tree" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <label value="Things in my house:"/> <tree flex="1" width="350" height="200" datasources="things.rdf" ref="urn:things:root"> <treecols> <treecol id="name" label="Name" primary="true" flex="1"/> <treecol id="material" label="Material" flex="1"/> </treecols> <template> <treechildren> <treeitem uri="rdf:*"> <treerow> <treecell label="rdf:http://www.xulplanet.com/rdf/example#name"/> <treecell label="rdf:http://www.xulplanet.com/rdf/example#material"/> </treerow> </treeitem> </treechildren> </template> </tree> </window>