Permalink
Browse files

example 5

  • Loading branch information...
1 parent 704c82a commit 6a50d8a3acb57062b5393e3031f0451c174dd978 @gigasquid committed Jul 6, 2011
Showing with 69 additions and 0 deletions.
  1. +32 −0 example_5.rb
  2. +37 −0 sample_input.txt
View
@@ -0,0 +1,32 @@
+require 'javalib/jena-2.6.4.jar'
+require 'javalib/arq-2.8.7.jar'
+require 'javalib/icu4j-3.4.4.jar'
+require 'javalib/iri-0.8.jar'
+require 'javalib/log4j-1.2.13.jar'
+require 'javalib/lucene-core-2.3.1.jar'
+require 'javalib/slf4j-api-1.5.8.jar'
+require 'javalib/slf4j-log4j12-1.5.8.jar'
+require 'javalib/stax-api-1.0.1.jar'
+require 'javalib/wstx-asl-3.2.9.jar'
+require 'javalib/xercesImpl-2.7.1.jar'
+require 'java'
+
+java_import 'com.hp.hpl.jena.rdf.model.ModelFactory'
+java_import 'com.hp.hpl.jena.util.FileManager'
+java_import 'java.io.InputStream'
+
+#Creating a model
+m = ModelFactory.create_default_model
+
+#Finding the input file using the Jena File Manager
+input_file = FileManager.get.open "sample_input.txt"
+
+#read the RDF/XML file
+m.read(input_file, nil)
+
+#write the RDF file out in a different format
+m.write(java.lang.System::out, "N-TRIPLE")
+
+
+
+
View
@@ -0,0 +1,37 @@
+<rdf:RDF
+ xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
+ xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
+ >
+ <rdf:Description rdf:nodeID="A0">
+ <vcard:Family>Smith</vcard:Family>
+ <vcard:Given>John</vcard:Given>
+ </rdf:Description>
+ <rdf:Description rdf:about='http://somewhere/JohnSmith/'>
+ <vcard:FN>John Smith</vcard:FN>
+ <vcard:N rdf:nodeID="A0"/>
+ </rdf:Description>
+ <rdf:Description rdf:about='http://somewhere/SarahJones/'>
+ <vcard:FN>Sarah Jones</vcard:FN>
+ <vcard:N rdf:nodeID="A1"/>
+ </rdf:Description>
+ <rdf:Description rdf:about='http://somewhere/MattJones/'>
+ <vcard:FN>Matt Jones</vcard:FN>
+ <vcard:N rdf:nodeID="A2"/>
+ </rdf:Description>
+ <rdf:Description rdf:nodeID="A3">
+ <vcard:Family>Smith</vcard:Family>
+ <vcard:Given>Rebecca</vcard:Given>
+ </rdf:Description>
+ <rdf:Description rdf:nodeID="A1">
+ <vcard:Family>Jones</vcard:Family>
+ <vcard:Given>Sarah</vcard:Given>
+ </rdf:Description>
+ <rdf:Description rdf:nodeID="A2">
+ <vcard:Family>Jones</vcard:Family>
+ <vcard:Given>Matthew</vcard:Given>
+ </rdf:Description>
+ <rdf:Description rdf:about='http://somewhere/RebeccaSmith/'>
+ <vcard:FN>Becky Smith</vcard:FN>
+ <vcard:N rdf:nodeID="A3"/>
+ </rdf:Description>
+</rdf:RDF>

0 comments on commit 6a50d8a

Please sign in to comment.