Re: How to retrieve data ?
Paul Everitt <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.rdf |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
FWIW, I find the rdfds lib from XULPlanet to be a helpful wrapper:
http://xulplanet.com/downloads/rdfds/
For example, it makes it easy to serialize your ds to a string, so you
can confirm that the parsing works correctly. I also find its API more
convenient.
Looking at your example, did you leave out the "#" in the property's
URL? The NS declaration in the RDF is:
xmlns:MYINFOS="http://www.myurl.com/rdf#"
...but in JS:
"http://www.myurl.com/myinfos/description"
--Paul
KDO wrote:
> Hi all,
>
> I have some trouble to retrieve data from an RDF file. The structure of my
> RDF looks like this:
>
> <?xml version="1.0"?>
> <!DOCTYPE overlay SYSTEM "chrome://foxguardian/locale/foxguardian.dtd">
> <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:MYINFOS="http://www.myurl.com/rdf#">
>
> <RDF:Seq RDF:about="http://www.myurl.com/myinfos">
> <RDF:li>
> <RDF:Description about="http://www.myurl.com/myinfos/ADMIN">
> <MYINFOS:name>ADMIN</MYINFOS:name>
> <MYINFOS:description>short description for admin</MYINFOS:description>
> </RDF:Description>
> </RDF:li>
> <RDF:li>
> <RDF:Description about="http://www.myurl.com/myinfos/USER">
> <MYINFOS:name>USER</MYINFOS:name>
> <MYINFOS:description>short description for user</MYINFOS:description>
> </RDF:Description>
> </RDF:li>
> </RDF:Seq>
> </RDF:RDF>
>
> i have a JS function whith a string param which can be 'ADMIN' or 'USER'
> and i want to retrieve the 'description' value.
>
> My JS function looks like this :
>
> function getDescription(usertype) {
> var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
> getService(Components.interfaces.nsIRDFService);
>
> var infos = rdfService.GetResource("http://www.myurl.com/myinfos/"+usertype);
>
> var desc = rdfService.GetResource("http://www.myurl.com/myinfos/description");
>
> var target = dsource.GetTarget(infos, desc, true);
>
> alert(target);
> }
> but target is always null. What's wrong ?
>
> NB: dsource has been retrieve during onload event of my xul form
>
>
> KDO