Openanzo has a powerful RDF javascript library in the org.openanzo.js project. In previous posts I talked about some of the low level API available to create, store and find RDF statements. In this tutorial I’ll talk about a simple object called anzo.rdf.GraphResource which takes a graph and resource and creates a bean with familiar getters and setters to allow you to easily modify the properties of that resource.
  
 dojo.require("anzo.rdf.NamedGraph");
 dojo.require("anzo.rdf.GraphResource");

 // register namespaces to make this example simpler
 anzo.rdf.registerNamespace("ex", "http://www.example.org/");
 anzo.rdf.registerNamespace("foaf", "http://xmlns.com/foaf/0.1/");

 // 1. build a sample graph with some data in it
 var graph = new anzo.rdf.NamedGraph('http://graph_1');
 graph.add('ex:me', "foaf:firstName", "Rouben");
 graph.add('ex:me', "foaf:surname", "Meschian");
 graph.add('ex:me', "foaf:knows", "ex:sean");

 // 2. create a bean and specify which properties you want to create methods for
 var bean = new anzo.rdf.GraphResource('ex:me', graph, [ "foaf:firstName", "foaf:surname" ]);
 bean.getFirstName(); // returns a single literal "Rouben"
 bean.setSurname("Smith"); // sets my surname to "Smith"

 // 3. add additional properties whenever you want
 bean.createPropertyMethods(["foaf:knows"]);
 bean.addKnows("ex:ben");
 bean.getKnows(); // returns an array with Sean and Ben's URIs