Previous Topic

Next Topic

Creating Nodes and Triples

Nodes and tiples are created using a GraphElementFactory that is obtained from a JRDF graph using the graph's getElementFactory() method. The following code creates example nodes and triples:

//get the Factory
GraphElementFactory elementFactory = graph.getElementFactory();

//create resources
URIReference person = elementFactory.createResource(new URI("http://example.org/staffid#85740"));
BlankNode address = elementFactory.createResource();

//create properties
URIReference hasAddress = elementFactory.createResource(new URI("http://example.org/terms#address"));
URIReference hasStreet = elementFactory.createResource(new URI("http://example.org/terms#street"));
URIReference hasCity = elementFactory.createResource(new URI("http://example.org/terms#city"));
URIReference hasState = elementFactory.createResource(new URI("http://example.org/terms#state"));
URIReference hasPostCode = elementFactory.createResource
(new URI("http://example.org/terms#postalCode"));

//create values
Literal street = elementFactory.createLiteral("1501 Grant Avenue");
Literal city = elementFactory.createLiteral("Bedford");
Literal state = elementFactory.createLiteral("Massachusetts");
Literal postCode = elementFactory.createLiteral("01730");

//create statements
Triple addressStatement = elementFactory.createTriple(person, hasAddress, address);
Triple streetStatement = elementFactory.createTriple(address, hasStreet, street);
Triple cityStatement = elementFactory.createTriple(address, hasCity, city);
Triple stateStatement = elementFactory.createTriple(address, hasState, state);
Triple postCodeStatement = elementFactory.createTriple(address, hasPostCode, postCode);

See Also

JRDF Tutorial

Prerequisites

Obtaining a Session from a Kowari Server

Comparison of JRDF Graph Implementations

Creating the Graph

Adding Triples to the Graph

Searching the Graph

Reify Triples

Removing Triples from the Graph

Latest News

Kowari 1.1.0 Pre-release 1 Released

Kowari 1.0.5 Released

Kowari 1.0.4.1 Released

Kowari 1.0.4 Released

DAWG Evaluates iTQL

Kowari article in XML.com

Kowari mentioned on XML.com

Kowari 1.0.3 Released

Kowari Lite Introduced

Kowari 1.0.2 Released

Kowari 1.0.1 Released

View all news items


Open Source logo Tucana Technologies Logo SourceForge.net Logo

© 2001-2004 Tucana Technologies, Inc. Some rights reserved.