Changes between Version 2 and Version 3 of WikiStart


Ignore:
Timestamp:
04/04/05 13:47:24 (19 years ago)
Author:
kiesel
Comment:

added images, small fixes

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v2 v3  
    11== 1. Introduction == 
    22 
    3 rdf2java is a small tool written in Java. It allows an easy handling with RDF data. Instead of using an RDF api for creating and searching for RDF triples, i.e., (subject, predicate, object), you just work with Java objects representing RDF subjects / objects. 
    4  
    5 Normally, you'd first create an RDFS (RDF Schema) file, containing declarations for classes and properties. RDF data (e.g. in an RDF file) would refer to this RDFS file, just like an XML file can refer to a DTD or to an XML Schema file. The RDF Schema specifies what kind of RDF subjects (i.e. instances of these classes) would be allowed and how they would be linked to each other (-> properties). 
     3rdf2java is a small tool written in Java. It allows easy handling of RDF data. Instead of using an RDF api for creating and searching for RDF triples, i.e., (subject, predicate, object), you just work with Java objects representing RDF subjects / objects. 
     4 
     5Typically, you first create an RDFS (RDF Schema) file, containing declarations for classes and properties. RDF data (e.g. in an RDF file) refers to this RDFS file, just like an XML file can refer to a DTD or to an XML Schema file. The RDF Schema specifies what kind of RDF subjects (i.e. instances of these classes) are allowed and how they are linked to each other (-> properties). 
    66So, you have RDFS specifications and RDF data (instances) matching this RDF Schema. 
    77 
    8 Similarly we first create (generate) Java classes corresponding to the RDFS classes. Then we can "read in" RDF data, which are instances of RDFS classes and convert them to Java objects, being instances of the respective Java classes. 
     8Using rdf2java (or, to be more precise, the rdfs2class utility of the rdf2java package), we first create Java classes corresponding to the RDFS classes. Then we can use rdf2java to "read in" RDF data, and convert them to Java objects, being instances of the respective Java classes. 
    99 
    1010The original tool was written by Michael Sintek. Information and download of the old tool can be found [http://www.dfki.uni-kl.de/frodo/rdf2java/ here]. 
     
    9595}}} 
    9696 
    97 When you visualize these set of triples you receive the following picture (only the RDF data is shown, not the RDF Schema). Boxes represent resources (RDF subjects) whereas ellipses show literals (strings), which can only be RDF objects. The named and directed edges visualize the predicates. Click on the image to get a bigger version. 
    98  
    99 XXX image missing 
    100 graph representation of these RDF triples 
     97When you visualize these set of triples you receive the following picture (only the RDF data is shown, not the RDF Schema). Boxes represent resources (RDF subjects) whereas ellipses show literals (strings), which can only be RDF objects. The named and directed edges visualize the predicates. 
     98 
     99http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example1.a.75.gif 
     100[[BR]] ''graph representation of these RDF triples'' 
    101101 
    102102This RDF data contains two Persons: Bart Simpson and Homer Simson, whereas Bart has a parent, namely Homer. 
     
    150150 
    151151== 1.5  Online documentation (javadoc) of the rdf2java API == 
    152 . . . can be found here XXX. 
     152. . . can be found [http://www.dfki.uni-kl.de/~schwarz/rdf2java/apidoc/index.html here]. 
    153153 
    154154== 2. Installation == 
    155155rdf2java is a pure java tool, written using Java 2, JDK 1.3.1_02. Hence, I propose to NOT use an older JDK. However, the sources are included, whereas you could try to recompile the tool with whatever JDK you like. If you are using JBuilder 6 (or later), you will even find a project file "rdf2java.jpx", so you can open it directly into the JBuilder IDE and compile it, debug it, whatever... 
    156156 
    157 Just download rdf2java.zip and extract it to some directory, e.g., C:\java\  (an rdf2java directory will be created there automatically). 
    158  
    159 Top-level directories: 
    160 doc      : documentation (javadoc) 
    161 import   : jar-files needed by rdf2java; these must be included in the CLASSPATH ("java -cp ..."), when using rdf2java. 
    162 lib      : jar-file of the rdf2java tool; of course this must be included in the CLASSPATH, as well. 
    163 src      : the complete source code 
    164 testdata : some test data for examples 
     157Just download [http://www.dfki.uni-kl.de/~schwarz/rdf2java.zip rdf2java.zip] and extract it to some directory, e.g., C:\java\  (an rdf2java directory will be created there automatically). 
     158 
     159Top-level directories:[[BR]] 
     160doc      : documentation (javadoc)[[BR]] 
     161import   : jar-files needed by rdf2java; these must be included in the CLASSPATH ("java -cp ..."), when using rdf2java.[[BR]] 
     162lib      : jar-file of the rdf2java tool; of course this must be included in the CLASSPATH, as well.[[BR]] 
     163src      : the complete source code[[BR]] 
     164testdata : some test data for examples[[BR]] 
    165165 
    166166All you need to use rdf2java is to get the CLASSPATH right, whenever starting a Java-VM. You can either set the CLASSPATH environment variable, or specify the classpath temporarily via the "-cp" parameter whenever you call the java interpreter. 
     
    239239However, the RDF/S files found there are slightly different than the one's I pasted above. That's because they have been generated using Protégé-2000 and, hence, they contain additional, Protégé-2000 specific modeling. Also the generated Java class org.dfki.rdf2java.example1.Person is a bit more complex than the structure snipped above, but after having a look at it, you should roughly get the picture. Besides, although you can, you won't look into these classes very often. They are structures for keeping and representing some RDF data. In most cases, you will do nothing more than just call the getters and putters of these objects. 
    240240 
    241 4. RDF Import / Export (RDF data <--> Java instances) 
    242 Look at SimpleImportExport.java to get an understanding of how the import / export works. 
     241== 4. RDF Import / Export (RDF data <--> Java instances) == 
     242 
     243Look at !SimpleImportExport.java to get an understanding of how the import / export works. 
    243244For a better understanding I pasted an extract of the most important parts of the code below (marginal stuff like, e.g., exception handling has been removed): 
    244245 
     
    333334Assume further we want to assign a new object for Lisa Simpson plus relevant relationships to this knowledge base. You see the graphical representation of the RDF data to assign on the right image below. We will see below, the assignment won't lead to the result you might expect. Later we will show the correct RDF data to assign... 
    334335 
    335          <-  
    336  
    337 XXX image missing  
    338  
    339          
    340 the knowledge base so far 
    341          
    342         RDF data to assign to the knowledge base 
     336http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.a.short.75.gif 
     337[[BR]] ''the knowledge base so far'' 
     338 
     339http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.b.short.gif 
     340[[BR]] ''RDF data to assign to the knowledge base'' 
    343341 
    344342When looking at these pictures, keep in mind, that they are nothing more than the graphical representation of RDF triples; boxes represent RDF resources, ellipses represent literals (strings). Via rdf2java, resources (boxes) for instances of RDFS classes are represented by corresponding Java objects in the knowledge base, and outgoing edges are stored in these Java objects and are available via getter methods. 
     
    355353The result (knowledge base) is as follows: 
    356354 
    357  
     355http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.c.short.75.gif 
    358356 
    359357The result is not quite the one, you might have expected when I started this example. There are several mistakes: The Bart object forgot about his name. Then it still "knows" about his parent, but the Homer object doesn't reflect this relationship. As RDF/S doesn't know anything about inverse slots, this is this correct RDF. Finally it's not quite what we wanted to receive. The problem arose right at the beginning, where we specified, what RDF data to assign to the knowledge base. Let's make another assignment: 
    360358 
    361          <-  
    362  
    363   
    364  
    365          
    366 the knowledge base so far 
    367          
    368         RDF data to assign to the knowledge base 
     359http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.a.short.75.gif 
     360[[BR]] ''the knowledge base so far'' 
     361 
     362http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.b2.short.75.gif    
     363[[BR]] ''RDF data to assign to the knowledge base'' 
    369364 
    370365Note, that example1:example1_00005 (on the right image) will only be represented by an RDFResource object, because the right-side Homer object just needs to links to a reference of this resource. There's no need to know about about or change this resource. The Homer object has to be changed because of the hasChild property. Hence, we need to represent that by a THING object and add / change the property values we like. 
    371366However, the result of this assignment will be as follows: 
    372367 
    373  
     368http://www.dfki.uni-kl.de/~schwarz/rdf2java/testdata/example/example2.d.short.75.gif 
    374369 
    375370== 6. Additional Stuff == 
    376 In addition to really needed stuff like, e.g., the KnowledgeBase class, other useful tools emerged naturally. 
     371In addition to really needed stuff like, e.g., the !KnowledgeBase class, other useful tools emerged naturally. 
    377372 
    378373== 6.1  RDF Diff (dfki.rdf.util.RDFDiff) ==