![]() |
![]() |
![]() |
Redland RDF Library Manual | ![]() |
---|---|---|---|---|
typedef librdf_node; enum librdf_node_type; librdf_node* librdf_new_node (librdf_world *world); librdf_node* librdf_new_node_from_uri_string (librdf_world *world, unsigned char *uri_string); librdf_node* librdf_new_node_from_uri (librdf_world *world, librdf_uri *uri); librdf_node* librdf_new_node_from_uri_local_name (librdf_world *world, librdf_uri *uri, unsigned char *local_name); librdf_node* librdf_new_node_from_normalised_uri_string (librdf_world *world, unsigned char *uri_string, librdf_uri *source_uri, librdf_uri *base_uri); librdf_node* librdf_new_node_from_literal (librdf_world *world, unsigned char *string, const char *xml_language, int is_wf_xml); librdf_node* librdf_new_node_from_typed_literal (librdf_world *world, unsigned char *value, const char *xml_language, librdf_uri *datatype_uri); librdf_node* librdf_new_node_from_typed_counted_literal (librdf_world *world, unsigned char *value, size_t value_len, const char *xml_language, size_t xml_language_len, librdf_uri *datatype_uri); librdf_node* librdf_new_node_from_blank_identifier (librdf_world *world, unsigned char *identifier); librdf_node* librdf_new_node_from_node (librdf_node *node); void librdf_free_node (librdf_node *node); librdf_uri* librdf_node_get_uri (librdf_node *node); librdf_node_type librdf_node_get_type (librdf_node *node); unsigned char* librdf_node_get_literal_value (librdf_node *node); unsigned char* librdf_node_get_literal_value_as_counted_string (librdf_node *node, size_t *len_p); char* librdf_node_get_literal_value_as_latin1 (librdf_node *node); char* librdf_node_get_literal_value_language (librdf_node *node); int librdf_node_get_literal_value_is_wf_xml (librdf_node *node); librdf_uri* librdf_node_get_literal_value_datatype_uri (librdf_node *node); int librdf_node_get_li_ordinal (librdf_node *node); unsigned char* librdf_node_get_blank_identifier (librdf_node *node); int librdf_node_is_resource (librdf_node *node); int librdf_node_is_literal (librdf_node *node); int librdf_node_is_blank (librdf_node *node); size_t librdf_node_encode (librdf_node *node, unsigned char *buffer, size_t length); librdf_node* librdf_node_decode (librdf_world *world, size_t *size_p, unsigned char *buffer, size_t length); unsigned char* librdf_node_to_string (librdf_node *node); unsigned char* librdf_node_to_counted_string (librdf_node *node, size_t *len_p); void librdf_node_print (librdf_node *node, FILE *fh); int librdf_node_equals (librdf_node *first_node, librdf_node *second_node); librdf_iterator* librdf_node_static_iterator_create (librdf_node **nodes, int size);
typedef enum { LIBRDF_NODE_TYPE_UNKNOWN = 0, /* To catch uninitialised nodes */ LIBRDF_NODE_TYPE_RESOURCE = 1, /* rdf:Resource (& rdf:Property) - has a URI */ LIBRDF_NODE_TYPE_LITERAL = 2, /* rdf:Literal - has an XML string, language, XML space */ /* node type 3 is unused at present. Do not renumber this list. */ LIBRDF_NODE_TYPE_BLANK = 4, /* blank node has an identifier string */ LIBRDF_NODE_TYPE_LAST = LIBRDF_NODE_TYPE_BLANK } librdf_node_type;
Type of a redland node.
Better to check this with functions librdf_node_is_resource()
,
librdf_node_is_literal()
or librdf_node_is_blank()
.
librdf_node* librdf_new_node (librdf_world *world);
Constructor - create a new librdf_node object with a private identifier.
Calls librdf_new_node_from_blank_identifier(world, NULL) to construct a new redland blank node identifier and make a new librdf_node object for it.
|
redland world object |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_uri_string (librdf_world *world, unsigned char *uri_string);
Constructor - create a new librdf_node object from a URI string.
|
redland world object |
|
string representing a URI |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_uri (librdf_world *world, librdf_uri *uri);
Constructor - create a new resource librdf_node object with a given URI.
|
redland world object |
|
librdf_uri object |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_uri_local_name (librdf_world *world, librdf_uri *uri, unsigned char *local_name);
Constructor - create a new resource librdf_node object with a given URI and local name.
|
redland world object |
|
librdf_uri object |
|
local name to append to URI |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_normalised_uri_string (librdf_world *world, unsigned char *uri_string, librdf_uri *source_uri, librdf_uri *base_uri);
Constructor - create a new librdf_node object from a URI string normalised to a new base URI.
|
redland world object |
|
string representing a URI |
|
source URI |
|
base URI |
Returns : |
a new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_literal (librdf_world *world, unsigned char *string, const char *xml_language, int is_wf_xml);
Constructor - create a new literal librdf_node object.
0.9.12: xml_space argument deleted
An xml_language
cannot be used when is_wf_xml
is non-0. If both
are given, NULL is returned. If xml_language
is the empty string,
it is the equivalent to NULL.
|
redland world object |
|
literal string value |
|
literal XML language (or NULL, empty string) |
|
non 0 if literal is XML |
Returns : |
new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_typed_literal (librdf_world *world, unsigned char *value, const char *xml_language, librdf_uri *datatype_uri);
Constructor - create a new typed literal librdf_node object.
Only one of xml_language
or datatype_uri
may be given. If both
are given, NULL is returned. If xml_language
is the empty string,
it is the equivalent to NULL.
|
redland world object |
|
literal string value |
|
literal XML language (or NULL, empty string) |
|
URI of typed literal datatype or NULL |
Returns : |
new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_typed_counted_literal (librdf_world *world, unsigned char *value, size_t value_len, const char *xml_language, size_t xml_language_len, librdf_uri *datatype_uri);
Constructor - create a new typed literal librdf_node object.
Only one of xml_language
or datatype_uri
may be given. If both
are given, NULL is returned. If xml_language
is the empty string,
it is the equivalent to NULL.
|
redland world object |
|
literal string value |
|
literal string value length |
|
literal XML language (or NULL, empty string) |
|
literal XML language length (not used if xml_language is NULL)
|
|
URI of typed literal datatype or NULL |
Returns : |
new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_blank_identifier (librdf_world *world, unsigned char *identifier);
Constructor - create a new blank node librdf_node object from a blank node identifier.
If no identifier string is given, creates a new internal identifier and assigns it.
|
redland world object |
|
blank node identifier or NULL |
Returns : |
new librdf_node object or NULL on failure |
librdf_node* librdf_new_node_from_node (librdf_node *node);
Copy constructor - create a new librdf_node object from an existing librdf_node object.
|
librdf_node object to copy |
Returns : |
a new librdf_node object or NULL on failure |
void librdf_free_node (librdf_node *node);
Destructor - destroy an librdf_node object.
|
librdf_node object |
librdf_uri* librdf_node_get_uri (librdf_node *node);
Get the URI for a node object.
Returns a pointer to the URI object held by the node, it must be copied if it is wanted to be used by the caller.
|
the node object |
Returns : |
URI object or NULL if node has no URI. |
librdf_node_type librdf_node_get_type (librdf_node *node);
Get the type of the node.
|
the node object |
Returns : |
the node type |
unsigned char* librdf_node_get_literal_value (librdf_node *node);
Get the string literal value of the node.
Returns a pointer to the literal value held by the node, it must be copied if it is wanted to be used by the caller.
|
the node object |
Returns : |
the literal string or NULL if node is not a literal |
unsigned char* librdf_node_get_literal_value_as_counted_string (librdf_node *node, size_t *len_p);
Get the string literal value of the node as a counted string.
Returns a pointer to the literal value held by the node, it must be copied if it is wanted to be used by the caller.
|
the node object |
|
pointer to location to store length (or NULL) |
Returns : |
the literal string or NULL if node is not a literal |
char* librdf_node_get_literal_value_as_latin1 (librdf_node *node);
Get the string literal value of the node as ISO Latin-1.
Returns a newly allocated string containing the conversion of the UTF-8 literal value held by the node.
|
the node object |
Returns : |
the literal string or NULL if node is not a literal |
char* librdf_node_get_literal_value_language (librdf_node *node);
Get the XML language of the node.
Returns a pointer to the literal language value held by the node, it must be copied if it is wanted to be used by the caller.
|
the node object |
Returns : |
the XML language string or NULL if node is not a literal or there is no XML language defined. |
int librdf_node_get_literal_value_is_wf_xml (librdf_node *node);
Get the XML well-formness property of the node.
|
the node object |
Returns : |
0 if the XML literal is NOT well formed XML content, or the node is not a literal |
librdf_uri* librdf_node_get_literal_value_datatype_uri (librdf_node *node);
Get the typed literal datatype URI of the literal node.
|
the node object |
Returns : |
shared URI of the datatyped literal or NULL if the node is not a literal, or has no datatype URI |
int librdf_node_get_li_ordinal (librdf_node *node);
Get the node li object ordinal value.
|
the node object |
Returns : |
the li ordinal value or < 1 on failure |
unsigned char* librdf_node_get_blank_identifier (librdf_node *node);
Get the blank node identifier.
|
the node object |
Returns : |
the identifier value |
int librdf_node_is_resource (librdf_node *node);
Check node is a resource.
|
the node object |
Returns : |
non-zero if the node is a resource (URI) |
int librdf_node_is_literal (librdf_node *node);
Check node is a literal.
|
the node object |
Returns : |
non-zero if the node is a literal |
int librdf_node_is_blank (librdf_node *node);
Check node is a blank nodeID.
|
the node object |
Returns : |
non-zero if the node is a blank nodeID |
size_t librdf_node_encode (librdf_node *node, unsigned char *buffer, size_t length);
Serialise a node into a buffer.
Encodes the given node in the buffer, which must be of sufficient size. If buffer is NULL, no work is done but the size of buffer required is returned.
If the node cannot be encoded due to restrictions of the encoding format, a redland error is generated
|
the node to serialise |
|
the buffer to use |
|
buffer size |
Returns : |
the number of bytes written or 0 on failure. |
librdf_node* librdf_node_decode (librdf_world *world, size_t *size_p, unsigned char *buffer, size_t length);
Deserialise a node from a buffer.
Decodes the serialised node (as created by librdf_node_encode()
)
from the given buffer.
|
librdf_world |
|
pointer to bytes used or NULL |
|
the buffer to use |
|
buffer size |
Returns : |
new node or NULL on failure (bad encoding, allocation failure) |
unsigned char* librdf_node_to_string (librdf_node *node);
Format the node as a string.
Note a new string is allocated which must be freed by the caller.
|
the node object |
Returns : |
a string value representing the node or NULL on failure |
unsigned char* librdf_node_to_counted_string (librdf_node *node, size_t *len_p);
Format the node as a counted string.
Note a new string is allocated which must be freed by the caller.
|
the node object |
|
pointer to location to store length |
Returns : |
a string value representing the node or NULL on failure |
void librdf_node_print (librdf_node *node, FILE *fh);
Pretty print the node to a file descriptor.
This method is for debugging and the format of the output should not be relied on.
|
the node |
|
file handle |
int librdf_node_equals (librdf_node *first_node, librdf_node *second_node);
Compare two librdf_node objects for equality.
Note - for literal nodes, XML language, XML space and well-formness are presently ignored in the comparison.
|
first librdf_node node |
|
second librdf_node node |
Returns : |
non 0 if nodes are equal. 0 if not-equal or failure |
librdf_iterator* librdf_node_static_iterator_create (librdf_node **nodes, int size);
Create an iterator over an array of nodes.
This creates an iterator for an existing static array of librdf_node objects. It is mostly intended for testing iterator code.
|
static array of librdf_node objects |
|
size of array |
Returns : |
a librdf_iterator serialization of the nodes or NULL on failure |