private Dataset assemble(final Resource example) {
   Model model = example.getModel();
   model.setNsPrefix("ja", JA.getURI());
   //	    System.out.println("-------------");
   //	    RDFDataMgr.write(System.out, model, Lang.TTL) ;
   final InMemDatasetAssembler testAssembler = new InMemDatasetAssembler();
   return testAssembler.open(testAssembler, example, DEFAULT);
 }
 public static void main(String[] args) {
   Model m = ModelFactory.createDefaultModel();
   String nsA = "http://somewhere/else#";
   String nsB = "http://nowhere/else#";
   Resource root = m.createResource(nsA + "root");
   Property P = m.createProperty(nsA + "P");
   Property Q = m.createProperty(nsB + "Q");
   Resource x = m.createResource(nsA + "x");
   Resource y = m.createResource(nsA + "y");
   Resource z = m.createResource(nsA + "z");
   m.add(root, P, x).add(root, P, y).add(y, Q, z);
   System.out.println("# -- no special prefixes defined");
   m.write(System.out);
   System.out.println("# -- nsA defined");
   m.setNsPrefix("nsA", nsA);
   m.write(System.out);
   System.out.println("# -- nsA and cat defined");
   m.setNsPrefix("cat", nsB);
   m.write(System.out, "TURTLE");
 }
예제 #3
0
 /** Initialize the result model. */
 public void initResults() {
   testResults = ModelFactory.createDefaultModel();
   jena2 = testResults.createResource(BASE_RESULTS_URI + "#jena2");
   jena2.addProperty(
       RDFS.comment,
       testResults.createLiteral(
           "<a xmlns=\"http://www.w3.org/1999/xhtml\" href=\"http://jena.sourceforce.net/\">Jena2</a> includes a rule-based inference engine for RDF processing, "
               + "supporting both forward and backward chaining rules. Its OWL rule set is designed to provide sound "
               + "but not complete instance resasoning for that fragment of OWL/Full limited to the OWL/lite vocabulary. In"
               + "particular it does not support unionOf/complementOf.",
           true));
   jena2.addProperty(RDFS.label, "Jena2");
   testResults.setNsPrefix("results", OWLResults.NS);
 }
예제 #4
0
  public static void main(String... argv) throws Exception {
    // //Model model = ModelFactory.createDefaultModel() ;
    // //String x = "<s> <p> 'verify it works' ." ;
    //
    //
    // //Reader sr = getTTLReader();
    // //model.read(sr, "http://example/", "TTL") ;
    // //model.read(sr, "", "TTL") ;
    // //model.read( getRDFInput() );
    // Model ttl = ModelFactory.createDefaultModel().read( getTTLInput(),
    // "", "TTL");
    // Model rdf = ModelFactory.createDefaultModel().read( getRDFInput(),
    // "", "RDF/XML-ABBREV");
    //
    // ttl.write(System.out, "RDF/XML-ABBREV") ;
    // System.out.println("-----") ;
    // // model.setNsPrefix("ex", "http://example/") ;
    // rdf.write(System.out, "N-TRIPLES") ;
    // System.out.println("-----") ;
    // System.out.println( getTTLName() );
    // System.out.println( "ttl iso rdf: "+ttl.isIsomorphicWith(rdf));
    //
    // System.out.println( getRDFName() );
    // System.out.println( "rdf iso ttl: "+rdf.isIsomorphicWith(ttl));

    String[] lines = {
      "<rdf:RDF",
      "  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">",
      "  <rdf:Description rdf:about=\"e\">",
      "    <p5>verify base works</p5>",
      "  </rdf:Description>",
      "</rdf:RDF>"
    };

    String eol = System.getProperty("line.separator");
    StringBuilder sb = new StringBuilder();
    for (String l : lines) {
      sb.append(l).append(eol);
    }

    Model model = ModelFactory.createDefaultModel();

    StringReader sr = new StringReader(sb.toString());
    model.read(sr, "http://example/");
    model.write(System.out, "N-TRIPLES");
    System.out.println("-----");
    model.setNsPrefix("ex", "http://example/");
    model.write(System.out, "RDF/XML-ABBREV", "http://another/");
  }
예제 #5
0
 /** Constructor: initializes the Jena model. */
 public GAMSOModelMaker() {
   gamsoModel = ModelFactory.createDefaultModel();
   gamsoModel.setNsPrefix("skos", SKOS.getURI());
   gamsoModel.setNsPrefix("gamso", GAMSO_BASE_URI);
   gamsoModel.setNsPrefix("cspa-onto", CSPAOnto.getURI());
 }