Triples

Triples — RDF Triples

Synopsis

enum                raptor_genid_type;
enum                raptor_identifier_type;
                    raptor_identifier;
raptor_identifier*  raptor_new_identifier               (raptor_identifier_type type,
                                                         raptor_uri *uri,
                                                         raptor_uri_source uri_source,
                                                         unsigned char *id,
                                                         unsigned char *literal,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language);
int                 raptor_copy_identifier              (raptor_identifier *dest,
                                                         raptor_identifier *src);
void                raptor_free_identifier              (raptor_identifier *identifier);
                    raptor_statement;
int                 raptor_statement_compare            (const raptor_statement *s1,
                                                         const raptor_statement *s2);
void                raptor_print_statement              (const raptor_statement *statement,
                                                         FILE *stream);
void                raptor_print_statement_as_ntriples  (const raptor_statement *statement,
                                                         FILE *stream);
void                raptor_print_statement_detailed     (const raptor_statement *statement,
                                                         int detailed,
                                                         FILE *stream);
unsigned char*      raptor_statement_part_as_counted_string
                                                        (const void *term,
                                                         raptor_identifier_type type,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language,
                                                         size_t *len_p);
unsigned char*      raptor_statement_part_as_string     (const void *term,
                                                         raptor_identifier_type type,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language);

Description

Representation of RDF triples inside Raptor. They are a sequence of three raptor_identifier which cover the RDF terms of URI (RAPTOR_IDENTIFIER_TYPE_RESOURCE), Literal (RAPTOR_IDENTIFIER_TYPE_LITERAL) and Blank Node (RAPTOR_IDENTIFIER_TYPE_ANONYMOUS). Some other raptor_identifer_type forms exist but are deprecated.

Details

enum raptor_genid_type

typedef enum {
  RAPTOR_GENID_TYPE_BNODEID,
  RAPTOR_GENID_TYPE_BAGID
} raptor_genid_type;

Intended type for a generated identifier asked for by the handler registered with raptor_set_generate_id_handler().

RAPTOR_GENID_TYPE_BNODEID

Generated ID is for a blank node

RAPTOR_GENID_TYPE_BAGID

Generated ID is for rdf:bagID

enum raptor_identifier_type

typedef enum {
  RAPTOR_IDENTIFIER_TYPE_UNKNOWN,
  RAPTOR_IDENTIFIER_TYPE_RESOURCE,
  RAPTOR_IDENTIFIER_TYPE_ANONYMOUS,
  RAPTOR_IDENTIFIER_TYPE_PREDICATE,
  RAPTOR_IDENTIFIER_TYPE_ORDINAL,
  RAPTOR_IDENTIFIER_TYPE_LITERAL,
  RAPTOR_IDENTIFIER_TYPE_XML_LITERAL
} raptor_identifier_type;

Type of identifier in a raptor_statement

RAPTOR_IDENTIFIER_TYPE_UNKNOWN

Internal

RAPTOR_IDENTIFIER_TYPE_RESOURCE

Resource URI (e.g. rdf:about)

RAPTOR_IDENTIFIER_TYPE_ANONYMOUS

_:foo N-Triples, or generated

RAPTOR_IDENTIFIER_TYPE_PREDICATE

predicate URI. WARNING: Will not be generated in in Raptor 1.4.9 or newer. Instead a RAPTOR_IDENTIFIER_TYPE_RESOURCE will be returned.

RAPTOR_IDENTIFIER_TYPE_ORDINAL

rdf:li, rdf:_n. No longer generated in any parser in Raptor 1.4.10+, instead a RAPTOR_IDENTIFIER_TYPE_RESOURCE is returned.

RAPTOR_IDENTIFIER_TYPE_LITERAL

regular literal

RAPTOR_IDENTIFIER_TYPE_XML_LITERAL

rdf:parseType="Literal". No longer generated by any parser in Raptor 1.4.8+, instead a RAPTOR_IDENTIFIER_TYPE_LITERAL is returned with a datatype of rdf:XMLLiteral.

raptor_identifier

typedef struct {
  raptor_identifier_type type;
  raptor_uri *uri;
  raptor_uri_source uri_source;
  const unsigned char *id;
  int ordinal;
  int is_malloced;
  const unsigned char *literal;
  raptor_uri *literal_datatype;
  const unsigned char *literal_language;
  raptor_world *world;
} raptor_identifier;

Raptor RDF term identifier.

raptor_identifier_type type;

Type of identifier

raptor_uri *uri;

URI of identifier for types RAPTOR_IDENTIFIER_TYPE_RESOURCE and RAPTOR_IDENTIFIER_TYPE_PREDICATE

raptor_uri_source uri_source;

where the identifier (URI or blank node) came from

int ordinal;

integer ordinal for type RAPTOR_IDENTIFIER_TYPE_ORDINAL

int is_malloced;

internal

raptor_uri *literal_datatype;

RDF literal datatype URI for types RAPTOR_IDENTIFIER_TYPE_LITERAL and RAPTOR_IDENTIFIER_TYPE_XML_LITERAL

raptor_world *world;

raptor_world object

raptor_new_identifier ()

raptor_identifier*  raptor_new_identifier               (raptor_identifier_type type,
                                                         raptor_uri *uri,
                                                         raptor_uri_source uri_source,
                                                         unsigned char *id,
                                                         unsigned char *literal,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language);

Constructor - create a raptor_identifier.

Constructs a new identifier copying the URI, ID fields. SHARED means raptor_new_identifier owns this argument after calling.

raptor_init() MUST have been called before calling this function. Use raptor_new_identifier_v2() if using raptor_world APIs.

type :

raptor_identifier_type of identifier

uri :

raptor_uri of identifier (if relevant) (SHARED)

uri_source :

raptor_uri_source of URI (if relevant)

id :

string for ID or genid (if relevant) (SHARED)

literal :

string for literal (SHARED)

literal_datatype :

raptor_uri of identifier (SHARED)

literal_language :

literal language (SHARED)

Returns :

a new raptor_identifier object or NULL on failure

raptor_copy_identifier ()

int                 raptor_copy_identifier              (raptor_identifier *dest,
                                                         raptor_identifier *src);

Copy raptor_identifiers.

dest :

destination raptor_identifier (previously created)

src :

source raptor_identifier

Returns :

Non 0 on failure

raptor_free_identifier ()

void                raptor_free_identifier              (raptor_identifier *identifier);

Destructor - destroy a raptor_identifier object.

identifier :

raptor_identifier object

raptor_statement

typedef struct {
  const void *subject;
  raptor_identifier_type subject_type;
  const void *predicate;
  raptor_identifier_type predicate_type;
  const void *object;
  raptor_identifier_type object_type;
  raptor_uri *object_literal_datatype;
  const unsigned char *object_literal_language;
} raptor_statement;

An RDF triple

See raptor_identifier for a description of how the fields may be used. As returned by a parser statement_handler.

See also raptor_statement_v2.

const void *subject;

triple subject data

raptor_identifier_type subject_type;

triple subject type

const void *predicate;

triple predicate data

raptor_identifier_type predicate_type;

triple predicate type

const void *object;

triple object literal string

raptor_identifier_type object_type;

triple object type

raptor_uri *object_literal_datatype;

triple object literal datatype URI (or NULL)

raptor_statement_compare ()

int                 raptor_statement_compare            (const raptor_statement *s1,
                                                         const raptor_statement *s2);

Compare a pair of raptor_statement

If types are different, the raptor_identifier_type order is used. Resource and datatype URIs are compared with raptor_uri_compare(), blank nodes and literals with strcmp(). If one literal has no language, it is earlier than one with a language. If one literal has no datatype, it is earlier than one with a datatype.

raptor_init() MUST have been called before calling this function. Use raptor_statement_compare_v2() if using raptor_world APIs.

s1 :

first statement

s2 :

second statement

Returns :

<0 if s1 is before s2, 0 if equal, >0 if s1 is after s2

raptor_print_statement ()

void                raptor_print_statement              (const raptor_statement *statement,
                                                         FILE *stream);

Print a raptor_statement to a stream.

raptor_init() MUST have been called before calling this function. Use raptor_print_statement_v2() if using raptor_world APIs.

statement :

raptor_statement object to print

stream :

FILE* stream

raptor_print_statement_as_ntriples ()

void                raptor_print_statement_as_ntriples  (const raptor_statement *statement,
                                                         FILE *stream);

Print a raptor_statement in N-Triples form.

raptor_init() MUST have been called before calling this function. Use raptor_print_statement_as_ntriples_v2() if using raptor_world APIs.

statement :

raptor_statement to print

stream :

FILE* stream

raptor_print_statement_detailed ()

void                raptor_print_statement_detailed     (const raptor_statement *statement,
                                                         int detailed,
                                                         FILE *stream);

Warning

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

Print a raptor_statement to a stream in a detailed fashion.

raptor_init() MUST have been called before calling this function.

deprecated: an internal function, do not use.

No current difference from calling raptor_print_statement().

statement :

raptor_statement object to print

detailed :

unused

stream :

FILE* stream

raptor_statement_part_as_counted_string ()

unsigned char*      raptor_statement_part_as_counted_string
                                                        (const void *term,
                                                         raptor_identifier_type type,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language,
                                                         size_t *len_p);

Turns part of raptor statement into a N-Triples format counted string.

Turns the given term into an N-Triples escaped string using all the escapes as defined in http://www.w3.org/TR/rdf-testcases/ntriples

The part (subject, predicate, object) of the raptor_statement is typically passed in as term, the part type (subject_type, predicate_type, object_type) is passed in as type. When the part is a literal, the literal_datatype and literal_language fields are set, otherwise NULL (usually object_datatype, object_literal_language).

raptor_init() MUST have been called before calling this function. Use raptor_statement_part_as_counted_string_v2() if using raptor_world APIs.

term :

raptor_statement part (subject, predicate, object)

type :

raptor_statement part type

literal_datatype :

raptor_statement part datatype

literal_language :

raptor_statement part language

len_p :

Pointer to location to store length of new string (if not NULL)

Returns :

the new string or NULL on failure. The length of the new string is returned in *len_p if len_p is not NULL.

raptor_statement_part_as_string ()

unsigned char*      raptor_statement_part_as_string     (const void *term,
                                                         raptor_identifier_type type,
                                                         raptor_uri *literal_datatype,
                                                         unsigned char *literal_language);

Turns part of raptor statement into a N-Triples format string.

Turns the given term into an N-Triples escaped string using all the escapes as defined in http://www.w3.org/TR/rdf-testcases/ntriples

The part (subject, predicate, object) of the raptor_statement is typically passed in as term, the part type (subject_type, predicate_type, object_type) is passed in as type. When the part is a literal, the literal_datatype and literal_language fields are set, otherwise NULL (usually object_datatype, object_literal_language).

raptor_init() MUST have been called before calling this function. Use raptor_statement_part_as_string_v2() if using raptor_world APIs.

term :

raptor_statement part (subject, predicate, object)

type :

raptor_statement part type

literal_datatype :

raptor_statement part datatype

literal_language :

raptor_statement part language

Returns :

the new string or NULL on failure.


Navigation: Redland Home Page

Copyright 2000-2010 Dave Beckett