Redland RDF Library Manual | ||||
---|---|---|---|---|
Top | Description |
typedef librdf_model; typedef librdf_model_factory; int librdf_model_enumerate (librdf_world *world
,const unsigned int counter
,const char **name
,const char **label
); librdf_model * librdf_new_model (librdf_world *world
,librdf_storage *storage
,const char *options_string
); librdf_model * librdf_new_model_with_options (librdf_world *world
,librdf_storage *storage
,librdf_hash *options
); librdf_model * librdf_new_model_from_model (librdf_model *model
); void librdf_free_model (librdf_model *model
); int librdf_model_size (librdf_model *model
); int librdf_model_add (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,librdf_node *object
); int librdf_model_add_string_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,int is_wf_xml
); int librdf_model_add_typed_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,librdf_uri *datatype_uri
); int librdf_model_add_statement (librdf_model *model
,librdf_statement *statement
); int librdf_model_add_statements (librdf_model *model
,librdf_stream *statement_stream
); int librdf_model_remove_statement (librdf_model *model
,librdf_statement *statement
); int librdf_model_contains_statement (librdf_model *model
,librdf_statement *statement
); int librdf_model_has_arc_in (librdf_model *model
,librdf_node *node
,librdf_node *property
); int librdf_model_has_arc_out (librdf_model *model
,librdf_node *node
,librdf_node *property
); librdf_stream * librdf_model_as_stream (librdf_model *model
); librdf_stream * librdf_model_serialise (librdf_model *model
); librdf_stream * librdf_model_find_statements (librdf_model *model
,librdf_statement *statement
); #define LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL librdf_stream * librdf_model_find_statements_with_options (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
,librdf_hash *options
); librdf_iterator * librdf_model_get_sources (librdf_model *model
,librdf_node *arc
,librdf_node *target
); librdf_iterator * librdf_model_get_arcs (librdf_model *model
,librdf_node *source
,librdf_node *target
); librdf_iterator * librdf_model_get_targets (librdf_model *model
,librdf_node *source
,librdf_node *arc
); librdf_node * librdf_model_get_source (librdf_model *model
,librdf_node *arc
,librdf_node *target
); librdf_node * librdf_model_get_arc (librdf_model *model
,librdf_node *source
,librdf_node *target
); librdf_node * librdf_model_get_target (librdf_model *model
,librdf_node *source
,librdf_node *arc
); librdf_iterator * librdf_model_get_arcs_in (librdf_model *model
,librdf_node *node
); librdf_iterator * librdf_model_get_arcs_out (librdf_model *model
,librdf_node *node
); int librdf_model_add_submodel (librdf_model *model
,librdf_model *sub_model
); int librdf_model_remove_submodel (librdf_model *model
,librdf_model *sub_model
); void librdf_model_print (librdf_model *model
,FILE *fh
); int librdf_model_context_add_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
); int librdf_model_context_add_statements (librdf_model *model
,librdf_node *context
,librdf_stream *stream
); int librdf_model_context_remove_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
); int librdf_model_context_remove_statements (librdf_model *model
,librdf_node *context
); librdf_stream * librdf_model_context_as_stream (librdf_model *model
,librdf_node *context
); librdf_stream * librdf_model_context_serialize (librdf_model *model
,librdf_node *context
); int librdf_model_contains_context (librdf_model *model
,librdf_node *context
); int librdf_model_supports_contexts (librdf_model *model
); librdf_query_results * librdf_model_query_execute (librdf_model *model
,librdf_query *query
); int librdf_model_sync (librdf_model *model
); librdf_storage * librdf_model_get_storage (librdf_model *model
); int librdf_model_load (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
); unsigned char * librdf_model_to_counted_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
,size_t *string_length_p
); unsigned char * librdf_model_to_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
); librdf_stream * librdf_model_find_statements_in_context (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
); librdf_iterator * librdf_model_get_contexts (librdf_model *model
); #define LIBRDF_MODEL_FEATURE_CONTEXTS librdf_node * librdf_model_get_feature (librdf_model *model
,librdf_uri *feature
); int librdf_model_set_feature (librdf_model *model
,librdf_uri *feature
,librdf_node *value
); int librdf_model_transaction_commit (librdf_model *model
); void * librdf_model_transaction_get_handle (librdf_model *model
); int librdf_model_transaction_rollback (librdf_model *model
); int librdf_model_transaction_start (librdf_model *model
); int librdf_model_transaction_start_with_handle (librdf_model *model
,void *handle
); int librdf_model_write (librdf_model *model
,raptor_iostream *iostr
);
The main user API class for Redland, providing access to the RDF graph and the triples in it (librdf_statement), storage, parsing, serializing and querying.
typedef struct librdf_model_factory_s librdf_model_factory;
Redland model factory class.
int librdf_model_enumerate (librdf_world *world
,const unsigned int counter
,const char **name
,const char **label
);
Get information on models.
|
redland world object |
|
index into the list of models |
|
pointer to store the name of the model (or NULL) |
|
pointer to store syntax readable label (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
librdf_model * librdf_new_model (librdf_world *world
,librdf_storage *storage
,const char *options_string
);
Constructor - create a new storage librdf_model object.
The options are encoded as described in librdf_hash_from_string()
and can be NULL if none are required.
|
redland world object |
|
librdf_storage to use |
|
options to initialise model |
Returns : |
a new librdf_model object or NULL on failure |
librdf_model * librdf_new_model_with_options (librdf_world *world
,librdf_storage *storage
,librdf_hash *options
);
Constructor - Create a new librdf_model with storage.
Options are presently not used.
|
redland world object |
|
librdf_storage storage to use |
|
librdf_hash of options to use |
Returns : |
a new librdf_model object or NULL on failure |
librdf_model * librdf_new_model_from_model (librdf_model *model
);
Copy constructor - create a new librdf_model from an existing one.
Creates a new model as a copy of the existing model in the same storage context.
|
the existing librdf_model |
Returns : |
a new librdf_model or NULL on failure |
void librdf_free_model (librdf_model *model
);
Destructor - Destroy a librdf_model object.
|
librdf_model model to destroy |
int librdf_model_size (librdf_model *model
);
Get the number of statements in the model.
WARNING: Not all underlying stores can return the size of the graph In which case the return value will be negative.
|
librdf_model object |
Returns : |
the number of statements or <0 if not possible |
int librdf_model_add (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,librdf_node *object
);
Create and add a new statement about a resource to the model.
After this method, the librdf_node objects become owned by the model. All of subject, predicate and object must be non-NULL.
|
model object |
|
librdf_node of subject |
|
librdf_node of predicate |
|
librdf_node of object (literal or resource) |
Returns : |
non 0 on failure |
int librdf_model_add_string_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,int is_wf_xml
);
Create and add a new statement about a literal to the model.
The language can be set to NULL if not used. All of subject, predicate and literal must be non-NULL.
0.9.12: xml_space argument deleted
|
model object |
|
librdf_node of subject |
|
librdf_node of predicate |
|
string literal conten |
|
language of literal |
|
literal is XML |
Returns : |
non 0 on failure |
int librdf_model_add_typed_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,librdf_uri *datatype_uri
);
Create and add a new statement about a typed literal to the model.
After this method, the librdf_node subject and predicate become owned by the model.
The language can be set to NULL if not used. All of subject, predicate and literal must be non-NULL.
|
model object |
|
librdf_node of subject |
|
librdf_node of predicate |
|
string literal content |
|
language of literal |
|
datatype librdf_uri |
Returns : |
non 0 on failure |
int librdf_model_add_statement (librdf_model *model
,librdf_statement *statement
);
Add a statement to the model.
The passed-in statement is copied when added to the model, not shared with the model. It must be a complete statement - all of subject, predicate, object parts must be present.
Only statements that are legal RDF can be added: URI or blank subject, URI predicate and URI or blank or literal object (i.e. anything).
If the statement already exists in the model, it is not added. Duplicate statements can be added when used with Redland Contexts such as with librdf_model_context_add_statement
|
model object |
|
statement object |
Returns : |
non 0 on failure |
int librdf_model_add_statements (librdf_model *model
,librdf_stream *statement_stream
);
Add a stream of statements to the model.
If any of the statements are illegal RDF statements they will be skipped and not added. See librdf_model_add_statement for the detail.
If any of the statements already exists in the store, they are not added unless Redland contexts are being used. See also librdf_model_context_add_statements
|
model object |
|
stream of statements to use |
Returns : |
non 0 on failure |
int librdf_model_remove_statement (librdf_model *model
,librdf_statement *statement
);
Remove a known statement from the model.
It must be a complete statement - all of subject, predicate, object parts must be present and a legal RDF triple.
|
the model object |
|
the statement |
Returns : |
non 0 on failure |
int librdf_model_contains_statement (librdf_model *model
,librdf_statement *statement
);
Check for a statement in the model.
It must be a complete statement - all of subject, predicate, object parts must be present and a legal RDF triple. Use librdf_model_find_statements to search for partial statement matches.
WARNING: librdf_model_contains_statement may not work correctly with stores using contexts. In this case, a search using librdf_model_find_statements for a non-empty list will return the correct result.
|
the model object |
|
the statement |
Returns : |
non 0 if the model contains the statement (>0 if the statement is illegal) |
int librdf_model_has_arc_in (librdf_model *model
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing to it.
|
librdf_model object |
|
librdf_node resource node |
|
librdf_node property node |
Returns : |
non 0 if arc property does point to the resource node |
int librdf_model_has_arc_out (librdf_model *model
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing from it.
|
librdf_model object |
|
librdf_node resource node |
|
librdf_node property node |
Returns : |
non 0 if arc property does point from the resource node |
librdf_stream * librdf_model_as_stream (librdf_model *model
);
List the model contents as a stream of statements.
|
the model object |
Returns : |
a librdf_stream or NULL on failure |
librdf_stream * librdf_model_serialise (librdf_model *model
);
Serialise the entire model as a stream (DEPRECATED).
DEPRECATED to reduce confusion with the librdf_serializer class. Please use librdf_model_as_stream.
|
the model object |
Returns : |
a librdf_stream or NULL on failure |
librdf_stream * librdf_model_find_statements (librdf_model *model
,librdf_statement *statement
);
Find matching statements in the model.
The partial statement is a statement where the subject, predicate and/or object can take the value NULL which indicates a match with any value in the model
|
the model object |
|
the partial statement to match |
Returns : |
a librdf_stream of statements (can be empty) or NULL on failure. |
#define LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL "http://feature.librdf.org/model-find-match-substring-literal"
Model find statement option.
If set, the find statement uses substring matching.
librdf_stream * librdf_model_find_statements_with_options (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
,librdf_hash *options
);
Search the model for matching statements with match options.
Searches the model for a (partial) statement as described in
librdf_statement_match()
and returns a librdf_stream of
matching librdf_statement objects.
If options is given then the match is made according to the given options. If options is NULL, this is equivalent to librdf_model_find_statements_in_context.
|
librdf_model object |
|
librdf_statement partial statement to find |
|
librdf_node context node or NULL. |
|
librdf_hash of matching options or NULL |
Returns : |
librdf_stream of matching statements (may be empty) or NULL on failure |
librdf_iterator * librdf_model_get_sources (librdf_model *model
,librdf_node *arc
,librdf_node *target
);
Return the sources (subjects) of arc in an RDF graph given arc (predicate) and target (object).
Searches the model for arcs matching the given arc and target and returns a list of the source librdf_node objects as an iterator
|
librdf_model object |
|
librdf_node arc |
|
librdf_node target |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_model_get_arcs (librdf_model *model
,librdf_node *source
,librdf_node *target
);
Return the arcs (predicates) of an arc in an RDF graph given source (subject) and target (object).
Searches the model for arcs matching the given source and target and returns a list of the arc librdf_node objects as an iterator
|
librdf_model object |
|
librdf_node source |
|
librdf_node target |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_model_get_targets (librdf_model *model
,librdf_node *source
,librdf_node *arc
);
Return the targets (objects) of an arc in an RDF graph given source (subject) and arc (predicate).
Searches the model for targets matching the given source and arc and returns a list of the source librdf_node objects as an iterator
|
librdf_model object |
|
librdf_node source |
|
librdf_node arc |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_node * librdf_model_get_source (librdf_model *model
,librdf_node *arc
,librdf_node *target
);
Return one source (subject) of arc in an RDF graph given arc (predicate) and target (object).
Searches the model for arcs matching the given arc and target and returns one librdf_node object
|
librdf_model object |
|
librdf_node arc |
|
librdf_node target |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node * librdf_model_get_arc (librdf_model *model
,librdf_node *source
,librdf_node *target
);
Return one arc (predicate) of an arc in an RDF graph given source (subject) and target (object).
Searches the model for arcs matching the given source and target and returns one librdf_node object
|
librdf_model object |
|
librdf_node source |
|
librdf_node target |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node * librdf_model_get_target (librdf_model *model
,librdf_node *source
,librdf_node *arc
);
Return one target (object) of an arc in an RDF graph given source (subject) and arc (predicate).
Searches the model for targets matching the given source and arc and returns one librdf_node object
|
librdf_model object |
|
librdf_node source |
|
librdf_node arc |
Returns : |
a new librdf_node object or NULL on failure |
librdf_iterator * librdf_model_get_arcs_in (librdf_model *model
,librdf_node *node
);
Return the properties pointing to the given resource.
|
librdf_model object |
|
librdf_node resource node |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
librdf_iterator * librdf_model_get_arcs_out (librdf_model *model
,librdf_node *node
);
Return the properties pointing from the given resource.
|
librdf_model object |
|
librdf_node resource node |
Returns : |
librdf_iterator of librdf_node objects (may be empty) or NULL on failure |
int librdf_model_add_submodel (librdf_model *model
,librdf_model *sub_model
);
Add a sub-model to the model.
FIXME: Not tested
|
the model object |
|
the sub model to add |
Returns : |
non 0 on failure |
int librdf_model_remove_submodel (librdf_model *model
,librdf_model *sub_model
);
Remove a sub-model from the model.
FIXME: Not tested
|
the model object |
|
the sub model to remove |
Returns : |
non 0 on failure |
void librdf_model_print (librdf_model *model
,FILE *fh
);
Print the model.
This method is for debugging and the format of the output should not be relied on.
Deprecated
: Use librdf_model_write()
to write to raptor_iostream
which can be made to write to a string. Use a librdf_serializer
to write proper syntax formats.
|
the model object |
|
the FILE stream to print to |
int librdf_model_context_add_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
);
Add a statement to a model with a context.
It must be a complete statement - all of subject, predicate, object parts must be present.
If context
is NULL, this is equivalent to librdf_model_add_statement
|
librdf_model object |
|
librdf_node context |
|
librdf_statement statement object |
Returns : |
Non 0 on failure |
int librdf_model_context_add_statements (librdf_model *model
,librdf_node *context
,librdf_stream *stream
);
Add statements to a model with a context.
If context
is NULL, this is equivalent to librdf_model_add_statements
|
librdf_model object |
|
librdf_node context |
|
librdf_stream stream object |
Returns : |
Non 0 on failure |
int librdf_model_context_remove_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
);
Remove a statement from a model in a context.
It must be a complete statement - all of subject, predicate, object parts must be present.
If context
is NULL, this is equivalent to librdf_model_remove_statement
|
librdf_model object |
|
librdf_node context |
|
librdf_statement statement |
Returns : |
Non 0 on failure |
int librdf_model_context_remove_statements (librdf_model *model
,librdf_node *context
);
Remove statements from a model with the given context.
|
librdf_model object |
|
librdf_node context |
Returns : |
Non 0 on failure |
librdf_stream * librdf_model_context_as_stream (librdf_model *model
,librdf_node *context
);
List all statements in a model context.
|
librdf_model object |
|
librdf_node context |
Returns : |
librdf_stream of statements or NULL on failure |
librdf_stream * librdf_model_context_serialize (librdf_model *model
,librdf_node *context
);
List all statements in a model context.
DEPRECATED to reduce confusion with the librdf_serializer class. Please use librdf_model_context_as_stream.
|
librdf_model object |
|
librdf_node context |
Returns : |
librdf_stream of statements or NULL on failure |
int librdf_model_contains_context (librdf_model *model
,librdf_node *context
);
Check for a context in the model.
|
the model object |
|
the contest |
Returns : |
non 0 if the model contains the context node |
int librdf_model_supports_contexts (librdf_model *model
);
Check if this model supports contexts
|
the model object |
Returns : |
non-0 if contexts are supported |
librdf_query_results * librdf_model_query_execute (librdf_model *model
,librdf_query *query
);
Execute a query against the model.
Run the given query against the model and return a librdf_stream of matching librdf_statement objects
|
librdf_model object |
|
librdf_query object |
Returns : |
librdf_query_results or NULL on failure |
int librdf_model_sync (librdf_model *model
);
Synchronise the model to the model implementation.
|
librdf_model object |
Returns : |
non-0 on failure |
librdf_storage * librdf_model_get_storage (librdf_model *model
);
Return the storage of this model.
Note: this can only return one storage, so model implementations that have multiple librdf_storage internally may chose not to implement this.
|
librdf_model object |
Returns : |
librdf_storage or NULL if this has no store |
int librdf_model_load (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
);
Load content from a URI into the model.
If the name field is NULL, the library will try to guess the parser to use from the uri, mime_type and type_uri fields. This is done via the raptor_guess_parser_name function.
|
librdf_model object |
|
the URI to read the content |
|
the name of the parser (or NULL) |
|
the MIME type of the syntax (NULL if not used) |
|
URI identifying the syntax (NULL if not used) |
Returns : |
non 0 on failure |
unsigned char * librdf_model_to_counted_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
,size_t *string_length_p
);
Write serialized model to a string.
If the name field is NULL, the default serializer will be used.
Note: the returned string must be freed by the caller using librdf_free_memory()
.
|
librdf_model object |
|
base URI to use in serializing (or NULL if not used) |
|
the name of the serializer (or NULL for default) |
|
the MIME type of the syntax (NULL if not used) |
|
URI identifying the syntax (NULL if not used) |
|
pointer to location to store string length (or NULL) |
Returns : |
new string or NULL on failure |
unsigned char * librdf_model_to_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
);
Write serialized model to a string.
If the name field is NULL, the default serializer will be used.
Note: the returned string must be freed by the caller.
|
librdf_model object |
|
base URI to use in serializing (or NULL if not used) |
|
the name of the serializer (or NULL for default) |
|
the MIME type of the syntax (NULL if not used) |
|
URI identifying the syntax (NULL if not used) |
Returns : |
new string or NULL on failure |
librdf_stream * librdf_model_find_statements_in_context (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
);
Search the model for matching statements in a given context.
Searches the model for a (partial) statement as described in
librdf_statement_match()
in the given context and returns a
librdf_stream of matching librdf_statement objects. If
context is NULL, this is equivalent to librdf_model_find_statements.
|
librdf_model object |
|
librdf_statement partial statement to find |
|
context librdf_node (or NULL) |
Returns : |
librdf_stream of matching statements (may be empty) or NULL on failure |
librdf_iterator * librdf_model_get_contexts (librdf_model *model
);
Return the list of contexts in the graph.
Returns an iterator of librdf_node context nodes for each context in the graph.
|
librdf_model object |
Returns : |
librdf_iterator of context nodes or NULL on failure or if contexts are not supported |
#define LIBRDF_MODEL_FEATURE_CONTEXTS "http://feature.librdf.org/model-contexts"
Model feature contexts.
If set, the model has redland contexts.
librdf_node * librdf_model_get_feature (librdf_model *model
,librdf_uri *feature
);
Get the value of a graph feature .
|
librdf_model object |
|
librdf_uri feature property |
Returns : |
new librdf_node feature value or NULL if no such feature exists or the value is empty. |
int librdf_model_set_feature (librdf_model *model
,librdf_uri *feature
,librdf_node *value
);
Set the value of a graph feature.
|
librdf_model object |
|
librdf_uri feature property |
|
librdf_node feature property value |
Returns : |
non 0 on failure (negative if no such feature) |
int librdf_model_transaction_commit (librdf_model *model
);
Commit a transaction.
|
the model object |
Returns : |
non-0 on failure |
void * librdf_model_transaction_get_handle (librdf_model *model
);
Get the current transaction handle.
|
the model object |
Returns : |
non-0 on failure |
int librdf_model_transaction_rollback (librdf_model *model
);
Rollback a transaction.
|
the model object |
Returns : |
non-0 on failure |
int librdf_model_transaction_start (librdf_model *model
);
Start a transaction
|
the model object |
Returns : |
non-0 on failure |
int librdf_model_transaction_start_with_handle (librdf_model *model
,void *handle
);
Start a transaction using an existing external transaction object.
|
the model object |
|
the transaction object |
Returns : |
non-0 on failure |
int librdf_model_write (librdf_model *model
,raptor_iostream *iostr
);
Write a model to an iostream in a debug format.
This method is for debugging and the format of the output should not be relied on. In particular, when contexts are used the result may be 4 nodes.
|
the model object |
|
the iostream to write to |
Returns : |
non-0 on failure |
Navigation: Redland Home Page