RDF term (librdf_node)

RDF term (librdf_node) — RDF triple component

Functions

void librdf_free_node ()
librdf_node * librdf_new_node ()
librdf_node * librdf_new_node_from_blank_identifier ()
librdf_node * librdf_new_node_from_counted_blank_identifier ()
librdf_node * librdf_new_node_from_counted_uri_string ()
librdf_node * librdf_new_node_from_literal ()
librdf_node * librdf_new_node_from_node ()
librdf_node * librdf_new_node_from_normalised_uri_string ()
librdf_node * librdf_new_node_from_typed_counted_literal ()
librdf_node * librdf_new_node_from_typed_literal ()
librdf_node * librdf_new_node_from_uri ()
librdf_node * librdf_new_node_from_uri_local_name ()
librdf_node * librdf_new_node_from_uri_string ()
librdf_node * librdf_node_decode ()
size_t librdf_node_encode ()
int librdf_node_equals ()
unsigned char * librdf_node_get_blank_identifier ()
unsigned char * librdf_node_get_counted_blank_identifier ()
int librdf_node_get_li_ordinal ()
unsigned char * librdf_node_get_literal_value ()
unsigned char * librdf_node_get_literal_value_as_counted_string ()
char * librdf_node_get_literal_value_as_latin1 ()
librdf_uri * librdf_node_get_literal_value_datatype_uri ()
int librdf_node_get_literal_value_is_wf_xml ()
char * librdf_node_get_literal_value_language ()
librdf_node_type librdf_node_get_type ()
librdf_uri * librdf_node_get_uri ()
int librdf_node_is_blank ()
int librdf_node_is_literal ()
int librdf_node_is_resource ()
librdf_iterator * librdf_node_new_static_node_iterator ()
void librdf_node_print ()
librdf_iterator * librdf_node_static_iterator_create ()
unsigned char * librdf_node_to_counted_string ()
unsigned char * librdf_node_to_string ()
int librdf_node_write ()

Types and Values

Description

The (subject, predicate, object) parts of an RDF triple.

Functions

librdf_free_node ()

void
librdf_free_node (librdf_node *node);

Destructor - destroy an librdf_node object.

Parameters

node

librdf_node object

 

librdf_new_node ()

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.

Parameters

world

redland world object

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_blank_identifier ()

librdf_node *
librdf_new_node_from_blank_identifier (librdf_world *world,
                                       const unsigned char *identifier);

Constructor - create a new blank node librdf_node object from a blank node identifier.

If no identifier string is given (NULL) this creates a new internal identifier and uses it.

Parameters

world

redland world object

 

identifier

UTF-8 encoded blank node identifier or NULL

 

Returns

new librdf_node object or NULL on failure


librdf_new_node_from_counted_blank_identifier ()

librdf_node *
librdf_new_node_from_counted_blank_identifier
                               (librdf_world *world,
                                const unsigned char *identifier,
                                size_t identifier_len);

Constructor - create a new blank node librdf_node object from a blank node counted length identifier.

If no identifier string is given (NULL) this creates a new internal identifier and uses it.

Parameters

world

redland world object

 

identifier

UTF-8 encoded blank node identifier or NULL

 

identifier_len

length of identifier

 

Returns

new librdf_node object or NULL on failure


librdf_new_node_from_counted_uri_string ()

librdf_node *
librdf_new_node_from_counted_uri_string
                               (librdf_world *world,
                                const unsigned char *uri_string,
                                size_t len);

Constructor - create a new librdf_node object from a counted URI string.

Parameters

world

redland world object

 

uri_string

string representing a URI

 

len

length of string

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_literal ()

librdf_node *
librdf_new_node_from_literal (librdf_world *world,
                              const 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.

Parameters

world

redland world object

 

string

literal UTF-8 encoded string value

 

xml_language

literal XML language (or NULL, empty string)

 

is_wf_xml

non 0 if literal is XML

 

Returns

new librdf_node object or NULL on failure


librdf_new_node_from_node ()

librdf_node *
librdf_new_node_from_node (librdf_node *node);

Copy constructor - create a new librdf_node object from an existing librdf_node object.

Parameters

node

librdf_node object to copy

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_normalised_uri_string ()

librdf_node *
librdf_new_node_from_normalised_uri_string
                               (librdf_world *world,
                                const unsigned char *uri_string,
                                librdf_uri *source_uri,
                                librdf_uri *base_uri);

Constructor - create a new librdf_node object from a UTF-8 encoded URI string normalised to a new base URI.

Parameters

world

redland world object

 

uri_string

UTF-8 encoded string representing a URI

 

source_uri

source URI

 

base_uri

base URI

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_typed_counted_literal ()

librdf_node *
librdf_new_node_from_typed_counted_literal
                               (librdf_world *world,
                                const 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.

Takes copies of the passed in value , datatype_uri and xml_language .

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.

Parameters

world

redland world object

 

value

literal UTF-8 encoded string value

 

value_len

literal string value length

 

xml_language

literal XML language (or NULL, empty string)

 

xml_language_len

literal XML language length (not used if xml_language is NULL)

 

datatype_uri

URI of typed literal datatype or NULL

 

Returns

new librdf_node object or NULL on failure


librdf_new_node_from_typed_literal ()

librdf_node *
librdf_new_node_from_typed_literal (librdf_world *world,
                                    const 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.

Parameters

world

redland world object

 

value

literal UTF-8 encoded string value

 

xml_language

literal XML language (or NULL, empty string)

 

datatype_uri

URI of typed literal datatype or NULL

 

Returns

new librdf_node object or NULL on failure


librdf_new_node_from_uri ()

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.

Parameters

world

redland world object

 

uri

librdf_uri object

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_uri_local_name ()

librdf_node *
librdf_new_node_from_uri_local_name (librdf_world *world,
                                     librdf_uri *uri,
                                     const unsigned char *local_name);

Constructor - create a new resource librdf_node object with a given URI and local name.

Parameters

world

redland world object

 

uri

librdf_uri object

 

local_name

local name to append to URI

 

Returns

a new librdf_node object or NULL on failure


librdf_new_node_from_uri_string ()

librdf_node *
librdf_new_node_from_uri_string (librdf_world *world,
                                 const unsigned char *uri_string);

Constructor - create a new librdf_node object from a URI string.

Parameters

world

redland world object

 

uri_string

string representing a URI

 

Returns

a new librdf_node object or NULL on failure


librdf_node_decode ()

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.

Parameters

world

librdf_world

 

size_p

pointer to bytes used or NULL

 

buffer

the buffer to use

 

length

buffer size

 

Returns

new node or NULL on failure (bad encoding, allocation failure)


librdf_node_encode ()

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

Parameters

node

the node to serialise

 

buffer

the buffer to use

 

length

buffer size

 

Returns

the number of bytes written or 0 on failure.


librdf_node_equals ()

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.

Parameters

first_node

first librdf_node node

 

second_node

second librdf_node node

 

Returns

non 0 if nodes are equal. 0 if not-equal or failure


librdf_node_get_blank_identifier ()

unsigned char *
librdf_node_get_blank_identifier (librdf_node *node);

Get the blank node identifier as a UTF-8 encoded string.

Parameters

node

the node object

 

Returns

the UTF-8 encoded blank node identifier value or NULL on failure


librdf_node_get_counted_blank_identifier ()

unsigned char *
librdf_node_get_counted_blank_identifier
                               (librdf_node *node,
                                size_t *len_p);

Get the blank node identifier as a counted UTF-8 encoded string.

Parameters

node

the node object

 

len_p

pointer to variable to store length (or NULL)

 

Returns

the UTF-8 encoded blank node identifier value or NULL on failure


librdf_node_get_li_ordinal ()

int
librdf_node_get_li_ordinal (librdf_node *node);

Get the node li object ordinal value.

Parameters

node

the node object

 

Returns

the li ordinal value or < 1 on failure


librdf_node_get_literal_value ()

unsigned char *
librdf_node_get_literal_value (librdf_node *node);

Get the literal value of the node as a UTF-8 encoded string.

Returns a pointer to the UTF-8 encoded literal value held by the node, it must be copied if it is wanted to be used by the caller.

Parameters

node

the node object

 

Returns

the UTF-8 encoded literal string or NULL if node is not a literal


librdf_node_get_literal_value_as_counted_string ()

unsigned char *
librdf_node_get_literal_value_as_counted_string
                               (librdf_node *node,
                                size_t *len_p);

Get the literal value of the node as a counted UTF-8 encoded string.

Returns a pointer to the UTF-8 encoded literal string value held by the node, it must be copied if it is wanted to be used by the caller.

Parameters

node

the node object

 

len_p

pointer to location to store the string length (or NULL)

 

Returns

the UTF-8 encoded literal string or NULL if node is not a literal


librdf_node_get_literal_value_as_latin1 ()

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 node literal value held by the node into ISO Latin-1. Discards characters outside the U+0000 to U+00FF range (inclusive).

Parameters

node

the node object

 

Returns

the Latin-1 literal string or NULL if node is not a literal


librdf_node_get_literal_value_datatype_uri ()

librdf_uri *
librdf_node_get_literal_value_datatype_uri
                               (librdf_node *node);

Get the typed literal datatype URI of the literal node.

Parameters

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


librdf_node_get_literal_value_is_wf_xml ()

int
librdf_node_get_literal_value_is_wf_xml
                               (librdf_node *node);

Get the XML well-formness property of the node.

Parameters

node

the node object

 

Returns

0 if the XML literal is NOT well formed XML content, or the node is not a literal


librdf_node_get_literal_value_language ()

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. Language strings are ASCII, not UTF-8 encoded Unicode.

Parameters

node

the node object

 

Returns

the XML language string or NULL if node is not a literal or there is no XML language defined.


librdf_node_get_type ()

librdf_node_type
librdf_node_get_type (librdf_node *node);

Get the type of the node.

See also librdf_node_is_resource(), librdf_node_is_literal() and librdf_node_is_blank() for testing individual types.

Parameters

node

the node object

 

Returns

the node type


librdf_node_get_uri ()

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.

Parameters

node

the node object

 

Returns

URI object or NULL if node has no URI.


librdf_node_is_blank ()

int
librdf_node_is_blank (librdf_node *node);

Check node is a blank nodeID.

Parameters

node

the node object

 

Returns

non-zero if the node is a blank nodeID


librdf_node_is_literal ()

int
librdf_node_is_literal (librdf_node *node);

Check node is a literal.

Parameters

node

the node object

 

Returns

non-zero if the node is a literal


librdf_node_is_resource ()

int
librdf_node_is_resource (librdf_node *node);

Check node is a resource.

Parameters

node

the node object

 

Returns

non-zero if the node is a resource (URI)


librdf_node_new_static_node_iterator ()

librdf_iterator *
librdf_node_new_static_node_iterator (librdf_world *world,
                                      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.

Parameters

world

world object

 

nodes

static array of librdf_node objects

 

size

size of array

 

Returns

a librdf_iterator serialization of the nodes or NULL on failure


librdf_node_print ()

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.

Parameters

node

the node

 

fh

file handle

 

librdf_node_static_iterator_create ()

librdf_iterator *
librdf_node_static_iterator_create (librdf_node **nodes,
                                    int size);

librdf_node_static_iterator_create is deprecated and should not be used in newly-written code.

Create an iterator over an array of nodes (ALWAYS FAILS)

This legacy method used to create an iterator for an existing static array of librdf_node objects. It was intended for testing iterator code.

deprecated : always returns NULL. Use librdf_node_new_static_node_iterator()

Parameters

nodes

static array of librdf_node objects

 

size

size of array

 

Returns

NULL


librdf_node_to_counted_string ()

unsigned char *
librdf_node_to_counted_string (librdf_node *node,
                               size_t *len_p);

librdf_node_to_counted_string is deprecated and should not be used in newly-written code.

Format the node as a counted string in a debugging format.

Note a new string is allocated which must be freed by the caller.

Deprecated : Use librdf_node_write() to write to raptor_iostream which can be made to write to a string. Use a librdf_serializer to write proper syntax formats.

Parameters

node

the node object

 

len_p

pointer to location to store length

 

Returns

a string value representing the node or NULL on failure


librdf_node_to_string ()

unsigned char *
librdf_node_to_string (librdf_node *node);

librdf_node_to_string is deprecated and should not be used in newly-written code.

Format the node as a string in a debugging format.

Note a new string is allocated which must be freed by the caller.

Deprecated : Use librdf_node_write() to write to raptor_iostream which can be made to write to a string. Use a librdf_serializer to write proper syntax formats.

Parameters

node

the node object

 

Returns

a string value representing the node or NULL on failure


librdf_node_write ()

int
librdf_node_write (librdf_node *node,
                   raptor_iostream *iostr);

Write the node to an iostream in N-Triples format.

This method can be used to write a node in a relatively readable format. To write more compact formats use a serializer to pick a syntax and serialize triples to it.

Parameters

node

the node

 

iostr

iostream to write to

 

Returns

non-0 on failure

Types and Values

librdf_node

typedef raptor_term librdf_node;

Redland node class.


enum 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().

Members

LIBRDF_NODE_TYPE_UNKNOWN

Internal

 

LIBRDF_NODE_TYPE_RESOURCE

rdf:Resource (& rdf:Property) - has a URI

 

LIBRDF_NODE_TYPE_LITERAL

rdf:Literal - has an XML string, language, XML space

 

LIBRDF_NODE_TYPE_BLANK

blank node has an identifier string.

 

LIBRDF_NODE_TYPE_LAST

Internal