4RDF

# 4RDF API

Uche
Ogbuji
Fourthought, Inc.

    uche.ogbuji@fourthought.com

1.1
2000-08-31
UO
Distributed with 4Suite 0.11.1

This document can be freely translated and distributed. It's released under the LDP License.

help
4Suite
API
4RDF
RDF
RIL
Inference
Application Programming Interface for 4RDF

# The 4RDF API

There is no standard API for RDF processors. We put together a simple, clean API that suits our uses of RDF very well. There are other APIs such as SIRPaC, RAX, none of which are supported by 4RDF now.

Please see the 4RDF command line documentation for command line help

Ft.Rdf.Model
integer NORMAL 0 A flag used in querying: indicates that search terms are to be exactly matched
integer IGNORE_CASE 1 A flag used in querying: indicates that search terms are to be matched regardless of case
integer REGEX 2 A flag used in querying: indicates that search terms are to be treated as regular expressions and matched accordingly
Model
Represents a universe of RDF statements, which at the abstract level represents a set of graphs that make up an RDF model
__init__
Initializer for an RDF model instance
driver
Any object meeting the protocol of Ft.Rdf.Drivers.Memory.Memory This is the object used to abstract the storage and management of the RDF statements. It could be a memory buffer, a DBMS connection, or even some code around a UserList
schemaHandler
Ft.Rdf.SchemaHandler.SchemaHandler This object is used to provide RDF schema support. If None, no schema support will be available for the resulting model. The default is None
addContainer
Add a container to the model. This involves adding a statement for the container type, and a container statement for each item in the collection
container
Ft.Rdf.Container.Container The container instance
extractContainer
Build a container object from the container item relationships in the model (_1, _2, etc.).
uri
Ft.Rdf.Container.Container The uri of the represented container
Ft.Rdf.Container.Container A container object (Bag, Alt or Set) representing all the container item relationships. Note that the returned object is not live. Changes to the model after the container is extracted will not affect the extracted container.
add
Add statement(s) to the model
statements
list of Rdf.Statement.Statement The new statement(s) to add to the model. Can be either a list of or a single Statement instance.
checkSchema
boolean 1 True enforces that the addition does not violate the RDF schema.
contains
Check if a statement is in the model
statement
Rdf.Statement.Statement The statement to check.
containsPattern
Determine if any statement matching the given criteria is in the model.
subject
string If not None, statements must have the given subject to match
predicate
string If not None, statements must have the given predicate to match
object
string If not None, statements must have the given object to match
statementUri
string None If not None, statements must have the given statementUri to match
sourceUri
string None If not None, statements must have the given sourceUri to match
subjectFlags
integer 0 Bit-wise OR'd module constants for matching the subject
predicateFlags
integer 0 Bit-wise OR'd module constants for matching the predicate
objectFlags
integer 0 Bit-wise OR'd module constants for matching the object
statementUriFlags
integer 0 Bit-wise OR'd module constants for matching the statementUri
sourceUriFlags
integer 0 Bit-wise OR'd module constants for matching the sourceUri
boolean True if any statements in the model match the given pattern
statements
Returns all the statments in the model
list of Ft.Rdf.Statement.Statement Sll the statements in the model
remove
Remove statement(s) from the model
statements
list of Rdf.Statement.Statement The statement(s) to remove. Can be either list of or single Ft.Rdf.Statement.Statement
removePattern
Remove all statements from the model that match the specified pattern
subject
string If not None, statements must have the given subject to match
predicate
string If not None, statements must have the given predicate to match
object
string If not None, statements must have the given object to match
statementUri
string None If not None, statements must have the given statementUri to match
sourceUri
string None If not None, statements must have the given sourceUri to match
subjectFlags
integer 0 Bit-wise OR'd module constants for matching the subject
predicateFlags
integer 0 Bit-wise OR'd module constants for matching the predicate
objectFlags
integer 0 Bit-wise OR'd module constants for matching the object
statementUriFlags
integer 0 Bit-wise OR'd module constants for matching the statementUri
sourceUriFlags
integer 0 Bit-wise OR'd module constants for matching the sourceUri
size
Returns the number of statements in the model
integer The number of statements in the model. Will be equal to or greater than 0
complete
Return all the statements in the model that match the given pattern.
subject
string If not None, statements must have the given subject to match
predicate
string If not None, statements must have the given predicate to match
object
string If not None, statements must have the given object to match
statementUri
string None If not None, statements must have the given statementUri to match
sourceUri
string None If not None, statements must have the given sourceUri to match
subjectFlags
integer 0 Bit-wise OR'd module constants for matching the subject
predicateFlags
integer 0 Bit-wise OR'd module constants for matching the predicate
objectFlags
integer 0 Bit-wise OR'd module constants for matching the object
statementUriFlags
integer 0 Bit-wise OR'd module constants for matching the statementUri
sourceUriFlags
integer 0 Bit-wise OR'd module constants for matching the sourceUri
list of Ft.Rdf.Statement.Statement The matching statements in the model.
exclude
Return all the statements in the model that DO NOT match the given pattern.
subject
string If not None, statements must have the given subject to match
predicate
string If not None, statements must have the given predicate to match
object
string If not None, statements must have the given object to match
statementUri
string None If not None, statements must have the given statementUri to match
sourceUri
string None If not None, statements must have the given sourceUri to match
subjectFlags
integer 0 Bit-wise OR'd module constants for matching the subject
predicateFlags
integer 0 Bit-wise OR'd module constants for matching the predicate
objectFlags
integer 0 Bit-wise OR'd module constants for matching the object
statementUriFlags
integer 0 Bit-wise OR'd module constants for matching the statementUri
sourceUriFlags
integer 0 Bit-wise OR'd module constants for matching the sourceUri
list of Ft.Rdf.Statement.Statement All statements in the model not matching the pattern.
generateUri
Generates URIs for "anonymous" resources, such as reified statements. The default method is to generate a UUID URN, but this can be easily overriden.
string A generated URI
Ft.Rdf.Statement
Statement
Represents an RDF triple or statement
__init__
Initializer for an RDF statement instance
subject
string The subject of the statement
predicate
string The predicate of the statement
object
string The object of the statement
uri
string '' The URI of the statement. This is an empty string except for very sophisticated use.
sourceUri
string '' The uri of the document containing this statement. This is an empty string except for very sophisticated use.
reify
Prepare the statement in the model so that it can be the subject of other statements. See the RDF spec for details of how statements are expanded for reification. Note that the original statement is not removed by reification. The statement's uri is used as the subject of the added statements, or a URI is generated if the statement's uri is an empty string.
model
Ft.Rdf.Model The model that is used to add the additional statements generated bu reification.
uri
string None URI to be assigned to the statement. If None, then first the statement object is checked for a URI, otherwise the model generates a URI for the reified statement. Default is None.
Ft.Rdf.SchemaHandler
SchemaHandler
Processing of RDF schema information on behalf of a model instance.
__init__
Initializer for a SchemaHandler. There are no parameters.
isCoreRdfs
Checks whether a statement comes from the core RDF meta-model.
stmt
Rdf.Statement.Statement The statement to check.
boolean 1 if the statement comes from the core RDF meta-model, otherwise 0.
isInstance
Checks whether a resource is an instance of a class. Note that this is also true if the resource is an instance of any subclass of the given class.
model
Rdf.Model.Model The model in which the condition is be checked
obj
string The URI of the resource to check for class membership.
class_
string The URI of the class to be checked.
boolean 1 if the statement is an instance of the class, otherwise 0.
isSubClass
Checks whether a class is an instance of another class.
model
Rdf.Model.Model The model in which the condition is be checked
class1
string The URI of the class to check as descendant.
class2
string The URI of the class to check as ancestor.
boolean 1 if the first class is a descendant of the second, otherwise 0.

Serializers create a serialized representation from an RDF model, or populate a model with statements from a serialized form. Currently the only built-in serializer for 4RDF handles a DOM form representing the XML serialization from the RDF Model and syntax recommendation.

Ft.Rdf.Serializers.Dom
Serialize or deserialize a model based on the XML serialization in the RDF Model and Syntax recommendation.
Serializer
Serialize or deserialize a model based on the XML serialization in the RDF Model and Syntax recommendation.
serialize
Construct a DOM representing statements in the model.
model
Ft.Rdf.Model The model from which the serialization is to be extracted
nsMap
dictionary None A mapping from URIs that are found in the model to prefixes that will be used for the corresponding XML namespaces in the serialization. If none, prefixes will be generated for each unique namespaceURI
selectUri
string None Only statements with this URI will be selected for serialization. If None, all statements will be serialized. Note that if the model is set up for schema validation, the RDFS schema statements are suppressed from the output.
implementation
xml.dom.DOMImplementation Ft.Lib.pDomlette.DOMImplementation An instance of a DOM implementation used to create the serialized document
xml.dom.Document The DOM Document node that represents the serialized document.
deserialize
Generate RDF statements from an XML serialization and insert these into a Model.
model
Ft.Rdf.Model The model into which the statements generated by the deserialization is to be entered.
node
xml.dom.Node The DOM node representing the serialization from which the statements are extracted.
sourceUri
string The base URI of the serialization. Usually this would be the URI of the document where the serialization is found.