On 25/03/12 14:18, vijayalakshmi wrote:
I did. I also read a tutorial given in the following link.

http://jena.sourceforge.net/tutorial/RDF_API/#ch-Jena RDF Packages

But then, I am not able to read the values and store it in a string in a
servlet.

This is what I have done so far.

//read the file into a model
model.read(files, null);

//read the domain
Resource vcard = model.getResource("http://www.wordpress.com/blogs/"; +
files);

The URI must match the resource you are trying to access. Unless "files" is set to "jhbh" then this won't match your data sample below.

String domain = vcard.getProperty(RDF.subject).getString();

If the input file is the following,

<rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
   <rdf:Description rdf:about="http://www.wordpress.com/blogs/jhbh";>
     <rdf:subject>Data structures</rdf:subject>

[Aside: That's a odd way to use rdf:subject, you may mean dcterms:subject.]

     <rdf:object></rdf:object>
     <rdf:value>hbl</rdf:value>
   </rdf:Description>
</rdf:RDF>

I want the String domain to be "Data Structures".

If I put that in a file "temp.rdf" and run:

    Model model = FileManager.get().loadModel("temp.rdf");
    Resource vcard = model.getResource(
           "http://www.wordpress.com/blogs/jhbh";);
    String domain = vcard.getProperty(RDF.subject).getString();
    System.out.println("Domain = " + domain);

I get:

    Domain = Data structures

Dave

Reply via email to