Mozilla RDF Javascript support
Part II of the seriesdiving into Mozilla.
Step1 - Download and Install jslib
from http://jslib.mozdev.org/downloads/index.html
and install it in your mozilla (it is a XPI, so no problem there)
Test the library by opening this url: chrome://jslib/content/
see also installation doc.
Step2 - write a XUL file to test
I did it with this ugly file that extracts the firstname from my public FOAF file: rdflib_hello (xul, 1 KB).
Step3 - configure it to run
The problem is that the XUL file must be placed where XUL files are usually placed. If you know how to do this, fine. If you don't, you have to configure jslib so that it accepts files outside the chrome. This may be a security risk. Description to use jslib from local XUL files.
Step4 - run rdflib_hello.xul
Start Mozilla, go to "open file" and open the XUL file (or use chrome:// if you managed to put it in your chrome).
You should see a single button. Press it and the String "Leo" should come.
What it does:
It loads my foaf file from my public homepage and extracts a literal property from a resource. To do this, there are fine XPCOM objects in Mozilla. But the XPCOM are hard to use, so the jslib guys made this system of Javascript helper objects to handle RDF. The script loads these jslib functions. Then, in the function testresult(), it uses an RDF object to get the RDF data from the homepage, select a resource from it and query an attribute of the resource.
You can also use the XPCOM RDF objects directly. So, at first glance Mozilla proves to be RDF-capable.
Simple XUL example
To get going with RDF in Mozilla, it is good to make a Hello World-kind of Application. I did this by the way of "jslib", a javascript library that helps Mozilla developers.Step1 - Download and Install jslib
from http://jslib.mozdev.org/downloads/index.html
and install it in your mozilla (it is a XPI, so no problem there)
Test the library by opening this url: chrome://jslib/content/
see also installation doc.
Step2 - write a XUL file to test
I did it with this ugly file that extracts the firstname from my public FOAF file: rdflib_hello (xul, 1 KB).
Step3 - configure it to run
The problem is that the XUL file must be placed where XUL files are usually placed. If you know how to do this, fine. If you don't, you have to configure jslib so that it accepts files outside the chrome. This may be a security risk. Description to use jslib from local XUL files.
Step4 - run rdflib_hello.xul
Start Mozilla, go to "open file" and open the XUL file (or use chrome:// if you managed to put it in your chrome).
You should see a single button. Press it and the String "Leo" should come.
What it does:
It loads my foaf file from my public homepage and extracts a literal property from a resource. To do this, there are fine XPCOM objects in Mozilla. But the XPCOM are hard to use, so the jslib guys made this system of Javascript helper objects to handle RDF. The script loads these jslib functions. Then, in the function testresult(), it uses an RDF object to get the RDF data from the homepage, select a resource from it and query an attribute of the resource.
You can also use the XPCOM RDF objects directly. So, at first glance Mozilla proves to be RDF-capable.
leobard - 21. May, 13:45
|
- add comment - 0 trackbacks