1libraptor(3) Library Functions Manual libraptor(3)
2
3
4
6 libraptor - Raptor RDF parser and serializer library
7
9 #include <raptor.h>
10
11 raptor_init();
12 raptor_parser *p=raptor_new_parser("rdfxml");
13 raptor_set_statement_handler(p,NULL,print_triples);
14 raptor_uri *file_uri=raptor_new_uri("http://example.org/");
15 raptor_parse_file(p,file_uri,base_uri);
16 raptor_parse_uri(p,uri,NULL);
17 raptor_free_parser(p);
18 raptor_free_uri(file_uri);
19 raptor_finish();
20
21 cc file.c -lraptor
22
24 The Raptor library provides a high-level interface to a set of parsers
25 and serializers that generate Resource Description Framework (RDF)
26 triples by parsing syntaxes or serialize the triples into syntaxes.
27
28 The supported parsing syntaxes are RDF/XML, N-Triples, Turtle, RSS tag
29 soup including Atom 0.3 and the serializing syntaxes are RDF/XML, N-
30 Triples and RSS 1.0. The RDF/XML parser can use either expat or libxml
31 XML parsers for providing the SAX event stream. The library functions
32 are arranged in an object-oriented style with constructors, destructors
33 and method calls. The statements and error messages are delivered via
34 callback functions.
35
36 Raptor contains a URI-reference parsing and resolving (not retrieval)
37 class (raptor_uri) sufficient for dealing with URI-references inside
38 RDF. This functionality is modular and can be transparently replaced
39 with another existing and compatible URI implementation.
40
41 It also provides a URI-retrieval class (raptor_www) for wrapping exist‐
42 ing library such as libcurl, libxml2 or BSD libfetch that provides full
43 or partial retrieval of data from URIs and an I/O stream abstraction
44 (raptor_iostream) for supportin serializing to a variety of outputs.
45
46 Raptor uses Unicode strings for RDF literals and URIs and preserves
47 them throughout the library. It uses the UTF-8 encoding of Unicode at
48 the API for passing in or returning Unicode strings. It is intended
49 that the preservation of Unicode for URIs will support International‐
50 ized Resource Identifiers (IRIs) which are still under development and
51 standardisation.
52
54 raptor_init()
55
56 raptor_finish()
57 Initialise and cleanup the library. These must be called before
58 any raptor class such as raptor_parser, raptor_uri is created or
59 used.
60
62 This class provides the functionality of turning syntaxes into RDF
63 triples - RDF parsing.
64
66 raptor_parser* raptor_new_parser(name)
67 Create a new raptor parser object for the parser with name name
68 currently either "rdfxml", "turtle" or "rss-tag-soup" for the
69 RSS Tag Soup parser.
70
71 raptor_parser* raptor_new_parser_for_content(raptor_uri *uri, const
72 char *mime_type, const unsigned char *buffer, size_t len, const
73 unsigned char *identifier)
74 Create a new raptor parser object for a syntax identified by URI
75 uri, MIME type mime_type, some initial content buffer of size
76 len or content with identifier identifier. See the rap‐
77 tor_guess_parser_name description for further details.
78
80 void raptor_free_parser(raptor_parser *parser)
81 Destroy a Raptor parser object.
82
84 Several methods can be registered for the parser that return a vari‐
85 able-argument message in the style of printf(3). These also return a
86 raptor_locator that can contain URI, file, line, column and byte counts
87 of where the message is about. This structure can be used with the rap‐
88 tor_format_locator, raptor_print_locator functions below or the struc‐
89 tures fields directly, which are defined in raptor.h
90
91 void raptor_set_fatal_error_handler(raptor_parser* parser, void
92 *user_data, raptor_message_handler handler)
93 Set the parser fatal error handler callback.
94
95 void raptor_set_error_handler(raptor_parser* parser, void *user_data,
96 raptor_message_handler handler)
97 Set the parser non-fatal error handler callback.
98
99 void raptor_set_warning_handler(raptor_parser* parser, void *user_data,
100 raptor_message_handler handler)
101 Set the parser warning message handler callback.
102
103 raptor_set_namespace_handler(raptor_parser* parser, void* user_data,
104 raptor_namespace_handler handler)
105 Set the namespace declaration handler callback.
106
108 The parser allows the registration of a callback function to return the
109 statements to the application.
110
111 void raptor_set_statement_handler(raptor_parser* parser, void
112 *user_data, raptor_statement_handler handler)
113 Set the statement callback function for the parser. The rap‐
114 tor_statement structure is defined in raptor.h and includes
115 fields for the subject, predicate, object of the statements
116 along with their types and for literals, language and datatype.
117
119 These methods perform the entire parsing in one method. Statements
120 warnings, errors and fatal errors are delivered via the registered
121 statement, error etc. handler functions.
122
123 In both of these methods, the base URI is required for the RDF/XML
124 parser (name "rdfxml") and Turtle parser (name "turtle"). The N-
125 Triples parser (name "ntriples") or RSS Tag Soup parser (name "rss-tag-
126 soup") do not use this.
127
128 int raptor_parse_file(raptor_parser* parser, raptor_uri *uri, rap‐
129 tor_uri *base_uri)
130 Parse the given filename (a URI like file:filename) according to
131 the optional base URI base_uri. If uri is NULL, read from stan‐
132 dard input and base_uri is then required.
133
134 int raptor_parse_file_stream(raptor_parser* parser, FILE* stream, const
135 char* filename, raptor_uri *base_uri)
136 Parse the given C FILE* stream according to the base URI
137 base_uri (required). filename is optional and if given, is used
138 for error messages via the raptor_locator structure.
139
140 int raptor_parse_uri(raptor_parser* parser, raptor_uri* uri, rap‐
141 tor_uri *base_uri)
142 Parse the URI according to the base URI base_uri, or NULL if not
143 needed. If no base URI is given, the uri is used. This method
144 depends on the raptor_www subsystem (see WWW Class section
145 below) and an existing underlying URI retrieval implementation
146 such as libcurl, libxml or BSD libfetch to retrieve the content.
147
149 These methods perform the parsing in parts by working on multiple
150 chunks of memory passed by the application. Statements warnings,
151 errors and fatal errors are delivered via the registered statement,
152 error etc. handler functions.
153
154 int raptor_start_parse(raptor_parser* parser, const char *uri)
155 Start a parse of chunked content with the base URI uri or NULL
156 if not needed. The base URI is required for the RDF/XML parser
157 (name "rdfxml") and Turtle parser (name "turtle"). The N-
158 Triples parser (name "ntriples") or RSS Tag Soup parser (name
159 "rss-tag-soup") do not use this.
160
161 int raptor_parse_chunk(raptor_parser* parser, const unsigned char
162 *buffer, size_t len, int is_end)
163 Parse the memory at buffer of size len returning statements via
164 the statement handler callback. If is_end is non-zero, it indi‐
165 cates the end of the parsing stream. This method can only be
166 called after raptor_start_parse().
167
169 const char* raptor_get_mime_type(raptor_parser* rdf_parser)
170 Return the MIME type for the parser.
171
172 void raptor_set_parser_strict(raptor_parser *parser, int is_strict)
173 Set the parser to strict (is_strict not zero) or lax (default)
174 mode. The detail of the strictness can be controlled by rap‐
175 tor_set_feature.
176
177 int raptor_set_feature(raptor_parser *parser, raptor_feature feature,
178 int value)
179 Set a parser feature feature to a particular value. Returns non
180 0 on failure or if the feature is unknown. The current defined
181 parser features are:
182 Feature Values
183 RAPTOR_FEATURE_ALLOW_BAGID Boolean (non 0 true)
184 RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES Boolean (non 0 true)
185 RAPTOR_FEATURE_ALLOW_OTHER_PARSETYPES Boolean (non 0 true)
186 RAPTOR_FEATURE_ALLOW_RDF_TYPE_RDF_LIST Boolean (non 0 true)
187 RAPTOR_FEATURE_ASSUME_IS_RDF Boolean (non 0 true)
188 RAPTOR_FEATURE_CHECK_RDF_ID Boolean (non 0 true)
189 RAPTOR_FEATURE_HTML_LINK Boolean (non 0 true)
190 RAPTOR_FEATURE_HTML_TAG_SOUP Boolean (non 0 true)
191 RAPTOR_FEATURE_MICROFORMATS Boolean (non 0 true)
192 RAPTOR_FEATURE_NON_NFC_FATAL Boolean (non 0 true)
193 RAPTOR_FEATURE_NORMALIZE_LANGUAGE Boolean (non 0 true)
194 RAPTOR_FEATURE_NO_NET Boolean (non 0 true)
195 RAPTOR_FEATURE_RELATIVE_URIS Boolean (non 0 true)
196 RAPTOR_FEATURE_SCANNING Boolean (non 0 true)
197 RAPTOR_FEATURE_WARN_OTHER_PARSETYPES Boolean (non 0 true)
198 RAPTOR_FEATURE_WWW_TIMEOUT Integer
199 RAPTOR_FEATURE_WWW_HTTP_CACHE_CONTROL String
200 RAPTOR_FEATURE_WWW_HTTP_USER_AGENT String
201
202 If the allow_bagid feature is true (default true) then the RDF/XML
203 parser will support the rdf:bagID attribute that was removed from the
204 RDF/XML language when it was revised. This support may be removed in
205 future.
206
207 If the allow_non_ns_attributes feature is true (default true), then the
208 RDF/XML parser will allow non-XML namespaced attributes to be accepted
209 as well as rdf: namespaced ones. For example, 'about' and 'ID' will be
210 interpreted as if they were rdf:about and rdf:ID respectively.
211
212 If the allow_other_parsetypes feature is true (default true) then the
213 RDF/XML parser will allow unknown parsetypes to be present and will
214 pass them on to the user. Unimplemented at present.
215
216 If the allow_rdf_type_rdf_list feature is true (default false) then the
217 RDF/XML parser will generate the idList rdf:type rdf:List triple in the
218 handling of rdf:parseType="Collection". This triple was removed during
219 the revising of RDF/XML after collections were initially added.
220
221 If the assume_is_rdf feature is true (default false), then the RDF/XML
222 parser will assume the content is RDF/XML, not require that rdf:RDF
223 root element, and immediately interpret the content as RDF/XML.
224
225 If the check_rdf_id feature is true (default true) then rdf:ID values
226 will be checked for duplicates and cause an error if found.
227
228 if the html_link feature is true (default true), look for head
229 <link> to type rdf/xml for GRDDL parser
230
231 If the html_tag_soup feature is true (default true), use a lax HTML
232 parser if an XML parser fails when read HTML for GRDDL parser.
233
234 If the microformats feature is true (default true), look for microfor‐
235 mats for GRDDL parser.
236
237 If the non_nfc_fatal feature is true (default false) then illegal Uni‐
238 code Normal Form C in literals will give a fatal error, otherwise it
239 gives a warning.
240
241 If the normalize_language feature is true (default true) then XML lan‐
242 guage values such as from xml:lang will be normalized to lowercase.
243
244 If the no_net feature is true (default false) then network requests are
245 denied.
246
247 If the scanning feature is true (default false), then the RDF/XML
248 parser will look for embedded rdf:RDF elements inside the XML content,
249 and not require that the XML start with an rdf:RDF root element.
250
251 If the www_timeout feature is set to an integer larger than 0, it sets
252 the timeout in seconds for internal WWW URI requests for the GRDDL
253 parser.
254
255 If the www_http_cache_control feature is set to a string value (default
256 none), it is sent as the value of the HTTP Cache-Control: header in
257 requests.
258
259 If the www_http_user_agent feature is set to a string value, it is sent
260 as the value of the HTTP User-Agent: header in requests.
261
262 raptor_parser_set_feature_string(raptor_parser *parser, raptor_feature
263 feature, const unsigned char *value)
264 Set a parser feature feature to a particular string value.
265 Returns non 0 on failure or if the feature is unknown. The cur‐
266 rent defined parser features are given in raptor_set_feature and
267 at present only take integer values. If an integer value feature
268 is set with this function, value is interpreted as an integer
269 and then that value is used.
270
271 int raptor_get_feature(raptor_parser* parser, raptor_feature feature)
272 Get parser feature integer values. The allowed feature values
273 and types are given under raptor_features_enumerate.
274
275 const unsigned char* raptor_parser_get_feature_string(raptor_parser
276 *parser, raptor_feature feature)
277 Get parser feature string values. The allowed feature values and
278 types are given under raptor_features_enumerate.
279
280 unsigned int raptor_get_feature_count(void)
281 Get the count of features defined. Prefered to the compile
282 time-only symbol RAPTOR_FEATURE_LAST which returns the maximum
283 value, not the count. Added raptor_get_need_base_uri
284
285 int raptor_feature_value_type(const raptor_feature feature)
286 Get a raptor feature value tyype - integer or string.
287
288 raptor_locator* raptor_get_locator(raptor_parser* rdf_parser)
289 Return the current raptor_locator object for the parser. This
290 is a public structure defined in raptor.h that can be used
291 directly, or formatted via raptor_print_locator.
292
293 void raptor_get_name(raptor_parser *parser)
294 Return the string short name for the parser.
295
296 void raptor_get_label(raptor_parser *parser)
297 Return a string label for the parser.
298
299 void raptor_set_default_generate_id_parameters(raptor_parser*
300 rdf_parser, char *prefix, int base)
301 Control the default method for generation of IDs for blank nodes
302 and bags. The method uses a short string prefix and an integer
303 base to generate the identifier which is not guaranteed to be a
304 strict concatenation. If prefix is NULL, the default is used.
305 If base is less than 1, it is initialised to 1.
306
307 void raptor_set_generate_id_handler(raptor_parser* parser, void
308 *user_data, raptor_generate_id_handler handler)
309 Allow full customisation of the generated IDs by setting a call‐
310 back handler and associated user_data that is called whenever a
311 blank node or bag identifier is required. The memory returned
312 is deallocated inside raptor. Some systems require this to be
313 allocated inside the same library, in which case the rap‐
314 tor_alloc_memory function may be useful.
315
316 void raptor_parser_set_uri_filter(raptor_parser* parser, rap‐
317 tor_uri_filter_func filter, void* user_data)
318 Set the URI filter function filter for URIs retrieved during
319 parsing by the the raptor_parser.
320
321 int raptor_get_need_base_uri(raptor_parser* rdf_parser)
322 Get a boolean whether this parser needs a base URI to start
323 parsing.
324
325 unsigned char* raptor_parser_generate_id(raptor_parser* rdf_parser,
326 raptor_genid_type type)
327 Generate an ID for a parser of type type, either RAP‐
328 TOR_GENID_TYPE_BNODEID or RAPTOR_GENID_TYPE_BAGID. This uses
329 any configuration set by raptor_set_generate_id_handler.
330
331 void raptor_set_graph_handler(raptor_parser* parser, void* user_data,
332 raptor_graph_handler handler)
333 Set the graph handler callback.
334
336 int raptor_parsers_enumerate(const unsigned int counter, const char
337 **name, const char **label)
338 Return the parser name/label for a parser with a given integer
339 counter, returning non-zero if no such parser at that offset
340 exists. The counter should start from 0 and be incremented by 1
341 until the function returns non-zero.
342
343 int raptor_syntaxes_enumerate(const unsigned int counter, const char
344 **name, const char **label, const char **mime_type, const unsigned char
345 **uri-string)
346 Return the name, label, mime type or URI string (all optional)
347 for a parser syntax with a given integer counter, returning non-
348 zero if no such syntax parser at that offset exists. The
349 counter should start from 0 and be incremented by 1 until the
350 function returns non-zero.
351
352 int raptor_features_enumerate(const raptor_feature feature, const char
353 **name, raptor_uri **uri, const char **label)
354 Return the name, URI, string label (all optional) for a parser
355 feature, returning non-zero if no such feature exists.
356
357 Raptor features have URIs that are constructed from the URI http://fea‐
358 ture.librdf.org/raptor- and the name so for example feature scanForRDF
359 has URI http://feature.librdf.org/raptor-scanForRDF
360
361 int raptor_syntax_name_check(const char *name)
362 Check name is a known syntax name.
363
364 const char* raptor_guess_parser_name(raptor_uri *uri, const char
365 *mime_type, const unsigned char *buffer, size_t len, const unsigned
366 char *identifier)
367 Guess a parser name for a syntax identified by URI uri, MIME
368 type mime_type, some initial content buffer of size len or with
369 content identifier identifier. All of these parameters are
370 optional and only used if not NULL. The parser is chosen by
371 scoring the hints that are given.
372
373 raptor_feature raptor_feature_from_uri(raptor_uri *uri)
374 Turn a URI uri into a raptor feature identifier, or <0 if the
375 feature is unknown. The URIs are described below rap‐
376 tor_set_feature.
377
379 int raptor_statement_compare(const raptor_statement *s1, const rap‐
380 tor_statement *s2)
381 Compare two statements and return an ordering between them.
382
383 void raptor_print_statement(const raptor_statement* const statement,
384 FILE *stream)
385 Print a raptor statement object in a simple format for debugging
386 only. The format of this output is not guaranteed to remain the
387 same between releases.
388
389 void raptor_print_statement_as_ntriples(const raptor_statement* state‐
390 ment, FILE *stream)
391 Print a raptor statement object in N-Triples format, using all
392 the escapes as defined in http://www.w3.org/TR/rdf-
393 testcases/#ntriples ⟨http://www.w3.org/TR/rdf-
394 testcases/#ntriples⟩
395
396 raptor_statement_part_as_counted_string(const void *term, raptor_iden‐
397 tifier_type type, raptor_uri* literal_datatype, const unsigned char
398 *literal_language, size_t* len_p)
399
400 char* raptor_statement_part_as_string(const void *term, raptor_identi‐
401 fier_type type, raptor_uri* literal_datatype, const unsigned char *lit‐
402 eral_language)
403 Turns part of raptor statement into N-Triples format, using all
404 the escapes as defined in http://www.w3.org/TR/rdf-
405 testcases/#ntriples ⟨http://www.w3.org/TR/rdf-
406 testcases/#ntriples⟩ The part (subject, predicate, object) of
407 the raptor_statement is passed in as term, the part type (sub‐
408 ject_type, predicate_type, object_type) is passed in as type.
409 When the part is a literal, the literal_datatype and lit‐
410 eral_language fields are set, otherwise NULL (usually
411 object_datatype, object_literal_language).
412
413 If raptor_statement_part_as_counted_string is used, the length
414 of the returned string is stored in *len_p if not NULL.
415
417 int raptor_format_locator(char *buffer, size_t length, raptor_locator*
418 locator)
419 This method takes a raptor_locator object as passed to an error,
420 warning or other handler callback and formats it into the buffer
421 of size length bytes. If buffer is NULL or length is insuffi‐
422 cient for the size of the formatted locator, returns the number
423 of additional bytes required in the buffer to write the locator.
424
425 In particular, if this form is used:
426 length=raptor_format_locator(NULL, 0, locator) it will return
427 in length the size of a buffer that can be allocated for locator
428 and a second call will perform the formatting:
429 raptor_format_locator(buffer, length, locator)
430
431
432 void raptor_print_locator(FILE *stream, raptor_locator* locator)
433 This method takes a raptor_locator object as passed to an error,
434 warning or other handler callback, formats and prints it to the
435 given stdio stream.
436
437 int raptor_locator_line(raptor_locator *locator)
438 Returns the line number in a locator structure or <0 if not
439 available.
440
441 int raptor_locator_column(raptor_locator *locator)
442 Returns the column number in a locator structure or <0 if not
443 available.
444
445 int raptor_locator_byte(raptor_locator *locator)
446 Returns the byte offset in a locator structure or <0 if not
447 available.
448
449 const char * raptor_locator_file(raptor_locator *locator)
450 Returns the filename in a locator structure or NULL if not
451 available. Note the returned pointer is to a shared string that
452 must be copied if needed.
453
454 const char * raptor_locator_uri(raptor_locator *locator)
455 Returns the URI string in a locator structure or NULL if not
456 available. Note this does not return a raptor_uri* pointer and
457 the returned pointer is to a shared string that must be copied
458 if needed.
459
461 void raptor_print_ntriples_string(FILE* stream, const char* string,
462 const char delim)
463 This is a standalone function that prints the given string
464 according to N-Triples escaping rules, expecting to be termi‐
465 nated by delimiter delim which is usually either ', " or <. If
466 a null delimiter \0 is given, no extra escaping is performed.
467
468 int raptor_iostream_write_string_ntriples(raptor_iostream *iostr, const
469 unsigned char *string, size_t len, const char delim)
470 Write an N-Triples encoded version of the given string to
471 iostream iostr. If delim is given, that is the ending delimeter
472 of the encoded string and it will be escaped in the output as
473 appropriate. Useful delim values are ', " and >. If a null
474 delimiter \0 is given, no extra escaping is performed.
475
476 int raptor_iostream_write_string_python(raptor_iostream *iostr, const
477 unsigned char *string, size_t len, const char delim, int flags)
478 Write string encoded to an iostream according to the delimeter
479 delim and encoding flags. The flag value selects formatting
480 according to the appropriate Python-related languages such as N-
481 Triples (0), Turtle (1), Turtle long quoted string (2), JSON
482 (3).
483
484 void raptor_iostream_write_statement_ntriples(raptor_iostream* iostr,
485 const raptor_statement *statement)
486 Write an N-Triples encoded version of the raptor_statement
487 statement to iostream iostr.
488
489 void raptor_iostream_write_string_turtle(raptor_iostream* iostr, const
490 unsigned char* string, size_t len)
491 DEPRECATED in 1.4.17 - use raptor_iostream_write_string_python
492 instead. Write an UTF-8 string of length len using the Turtle
493 "longString" triple quoting format to the iostream iostr.
494
495 const char* raptor_ntriples_term_as_string (raptor_ntriples_term_type
496 term)
497 Deprecated, for internal use.
498
500 int raptor_xml_any_escape_string(const unsigned char* string, size_t
501 len, unsigned char* buffer, size_t length, char quote, int xml_version,
502 raptor_simple_message_handler error_handler, void* error_data)
503
504 int raptor_xml_escape_string(const unsigned char *string, size_t len,
505 unsigned char *buffer, size_t length, char quote, raptor_message_han‐
506 dler error_handler, void *error_data)
507 Apply the XML escaping rules to the string given in (string,
508 len) into the buffer of size length. If quote is given, the
509 escaped content is for an XML attribute and the appropriate
510 quote character XML element content (CDATA). The error_handler
511 method along with error_data allow error reporting to be given.
512 If buffer is NULL, returns the size of the buffer required to
513 escape. Otherwise the return value is the number of bytes used
514 or <0 on failure.
515
516 When an xml_version argument is present and has a value 10 (XML
517 1.0) or 11 (XML 1.1) then that version is used. The default
518 with no argument is to generate XML 1.0.
519
520 int raptor_iostream_write_xml_any_escaped_string(raptor_iostream*
521 iostr, const unsigned char* string, size_t len, char quote, int
522 xml_version, raptor_simple_message_handler error_handler, void*
523 error_data)
524
525 int raptor_iostream_write_xml_escaped_string(raptor_iostream* iostr,
526 const unsigned char *string, size_t len, char quote, raptor_simple_mes‐
527 sage_handler error_handler, void *error_data)
528 Write an XML-escaped version of the string given in (string,
529 len) to iostream iostr. If quote is given, the escaped content
530 is for an XML attribute and the appropriate quote character is
531 used, otherwise it is XML element content (CDATA). The
532 error_handler method along with error_data allow error reporting
533 to be given.
534
535 When an xml_version argument is present and has a value 10 (XML
536 1.0) or 11 (XML 1.1) then that version is used. The default
537 with no argument is to generate XML 1.0.
538
539 int raptor_xml_name_check(const unsigned char *string, size_t length,
540 int xml_version)
541 Check that the given string of length bytes is a legal XML name
542 according to XML 1.0 or XML 1.1. xml_version is set to 10 or 11
543 respectively. Returns non-zero if the name is legal.
544
546 void raptor_free_memory(void *ptr)
547 Free memory allocated inside raptor. Some systems require mem‐
548 ory allocated in a library to be deallocated inside that
549 library. This function can be used in that situation to free
550 memory allocated by raptor, such as the result of the _to_ meth‐
551 ods that return allocated memory such as raptor_uri_to_filename,
552 raptor_uri_to_string, raptor_uri_to_relative_counted_uri_string,
553 raptor_uri_to_relative_uri_string or raptor_new_names‐
554 pace_parts_from_string.
555
556 void* raptor_alloc_memory(size_t size)
557 Allocate memory inside the raptor library. Some systems require
558 memory allocated in a library to be deallocated inside that
559 library. This function can be used in that situation to allo‐
560 cate memory for raptor to free later, such as inside the handler
561 function declared with raptor_set_generate_id_handler which
562 returns new memory.
563
564 void* raptor_calloc_memory(size_t nmemb, size_t size)
565 Allocate zeroed array of items inside raptor. Some systems
566 require memory allocated in a library to be deallocated inside
567 that library. This function can be used in that situation to
568 clear an array of allocated memory for raptor to use, for free‐
569 ing later, such as inside the handler function declared with
570 raptor_set_generate_id_handler which returns new memory.
571
573 int raptor_unicode_char_to_utf8(raptor_unichar c, unsigned char *out‐
574 put)
575 Turn a Unicode character into UTF8 bytes in output of size c
576 bytes which must be of sufficient size. Returns the number of
577 bytes encoded or <0 on failure.
578
579 int raptor_utf8_to_unicode_char(raptor_unichar *output, const unsigned
580 char *input, int length)
581 Decode a sequence UTF8 bytes in input of size length into a Uni‐
582 code character in output returning the number of bytes used or
583 <0 on failure.
584
585 int raptor_utf8_check(const unsigned char *string, size_t length)
586 Check that a given string is legal UTF-8 encoding and includes
587 only legal Unicode characters U+0 to U+0x10ffff inclusive.
588 Returns non-0 if the string is good.
589
590 int raptor_unicode_is_xml11_namestartchar(raptor_unichar c)
591
592 int raptor_unicode_is_xml10_namestartchar(raptor_unichar c)
593
594 int raptor_unicode_is_xml11_namechar(raptor_unichar c)
595
596 int raptor_unicode_is_xml10_namechar(raptor-unichar c)
597 Check that given Unicode characters are allowed as XML 1.0 or
598 XML 1.0 names - either as the starting character (*_names‐
599 tartchar) or continuing character (*_namechar). Returns non-0
600 if the character is allowed.
601
603 void raptor_error_handlers_init(raptor_error_handlers* error_handlers)
604 Initialise an error_handlers structure after the log level han‐
605 dlers and user data pointers have been set.
606
608 char* raptor_vsnprintf(const char *message, va_list arguments)
609 Compatibility wrapper around vsnprintf.
610
612 There are several read-only static variables in the raptor library:
613
614 const char * const raptor_short_copyright_string
615 Short copyright string, suitable for one line.
616
617 const char * const raptor_copyright_string
618 Full copyright over several lines including URLs.
619
620 const char * const raptor_version_string
621 The version as a string
622
623 const unsigned int raptor_version_major
624 The major version number as an integer.
625
626 const unsigned int raptor_version_minor
627 The minor version number as an integer.
628
629 const unsigned int raptor_version_release
630 The release version number as an integer.
631
632 const unsigned int raptor_version_decimal
633 The version number as a single decimal.
634
635 const char * const raptor_license_string
636 The license string over several lines including URLs.
637
638 const char * const raptor_home_url_string
639 The home page URL as a string.
640
642 This class provides the functionality of turning RDF triples into syn‐
643 taxes - RDF serializing.
644
646 raptor_serializer* raptor_new_serializer(const char *name)
647 Create a new raptor serializer object for the serializer with
648 name name currently either "rdfxml" or "ntriples". or "rss-1.0"
649 for the RSS 1.0 serializer.
650
652 void raptor_free_serializer(raptor_serializer* rdf_serializer)
653 Destroy a Raptor serializer object.
654
656 int raptor_serialize_start(raptor_serializer* rdf_serializer, rap‐
657 tor_uri *uri, raptor_iostream *iostream)
658 Start to serialize content using the given iostream to write to
659 with optional base URI uri. The iostream becomes owned by the
660 serializer object and is destroyed at the end of serializing
661 when raptor_serialize_end() is called. Note that some syntaxes
662 may refuse to serialize without a base URI, such as RDF/XML.
663
664 int raptor_serialize_start_to_iostream(raptor_serializer* rdf_serial‐
665 izer, raptor_uri* uri, raptor_iostream* iostream)
666 Start to serialize content using the given iostream to write to
667 with optional base URI uri. The iostream does NOT become owned
668 by the serializer object and the caller may continue to write to
669 it after serializing is finished. Note that some syntaxes may
670 refuse to serialize without a base URI, such as RDF/XML.
671
672 int raptor_serialize_start_to_filename(raptor_serializer* rdf_serial‐
673 izer, const char *filename)
674 Start to serialize content to the file filename which is opened
675 for writing. The base URI is calculated from the file name.
676
677 int raptor_serialize_start_to_string(raptor_serializer* rdf_serializer,
678 raptor_uri *uri, void **string_p, size_t *length_p)
679 Start to serialize content to a string. string_p must point to
680 a void* pointer that will be used at the end of serializing to
681 store the newly allocated string. length_p if not NULL, it will
682 be used to store the length of the new string. The serializing
683 is done with optional base URI uri however some syntaxes may
684 refuse to serialize without a base URI, such as RDF/XML.
685
686 int raptor_serialize_start_to_file_handle(raptor_serializer* rdf_seri‐
687 alizer, raptor_uri *uri, FILE *handle)
688 Start to serialize content to the already open C Standard I/O
689 FILE* handle with the base URI uri, which is optional and may be
690 NULL. Note that some syntaxes may refuse to serialize without a
691 base URI, such as RDF/XML.
692
693 int raptor_serialize_statement(raptor_serializer* rdf_serializer, const
694 raptor_statement *statement)
695 Serialize a single statement using the serializer.
696
697 int raptor_serialize_end(raptor_serializer* rdf_serializer)
698 End the serializing. This may close and delete resources used
699 in serializing. No more calls to raptor_serialize_statement or
700 raptor_serialize_end may be done at this point.
701
702 raptor_iostream* raptor_serializer_get_iostream(raptor_serializer
703 *serializer)
704 Return a pointer to the raptor_iostream* used by the serializer.
705
706 int raptor_serializer_set_namespace(raptor_serializer* serializer, rap‐
707 tor_uri *uri, const char *prefix)
708 Set a suggested namespace URI/prefix mapping for use in serial‐
709 izing.
710
712 void raptor_serializer_set_error_handler(raptor_serializer* serializer,
713 void *user_data, raptor_message_handler handler)
714 Set the serializer non-fatal error handler callback.
715
716 void raptor_serializer_set_warning_handler(raptor_serializer* serial‐
717 izer, void *user_data, raptor_message_handler handler)
718 Set the serializer warning message handler callback.
719
720 raptor_locator* raptor_serializer_get_locator(raptor_serializer*
721 rdf_serializer)
722 Return the current raptor_locator object for the serializer.
723 This is a public structure defined in raptor.h that can be used
724 directly, or formatted via raptor_print_locator.
725
726 int raptor_serializer_set_feature(raptor_serializer *serializer, rap‐
727 tor_feature feature, int value)
728 Set a serializer feature feature to a particular value. Returns
729 non 0 on failure or if the feature is unknown. The current
730 defined serializer features are:
731 Feature Values
732 RAPTOR_FEATURE_RELATIVE_URIS Boolean (non 0 true)
733 RAPTOR_FEATURE_WRITE_BASE_URI Boolean (non 0 true)
734 RAPTOR_FEATURE_START_URI URI String
735 RAPTOR_FEATURE_BNODE_BORDER String
736 RAPTOR_FEATURE_BNODE_FILL String
737 RAPTOR_FEATURE_JSON_CALLBACK String
738 RAPTOR_FEATURE_JSON_EXTRA_DATA String
739 RAPTOR_FEATURE_LITERAL_BORDER String
740 RAPTOR_FEATURE_LITERAL_FILL String
741 RAPTOR_FEATURE_RESOURCE_BORDER String
742 RAPTOR_FEATURE_RESOURCE_FILL String
743 RAPTOR_FEATURE_RSS_TRIPLES String
744 RAPTOR_FEATURE_ATOM_ENTRY_URI String
745
746
747 If the relative_uris feature is true (default false) then when serial‐
748 ising, preference is given to generating relative URIs where possible.
749
750 If the write_base_uri feature is true (default true) then the atom,
751 rdfxml, rdfxml-abbrev and turtle serializers will write an @base or
752 xml:base directive in the output.
753
754 If the start_uri feature is set to a URI it is used by the serializer
755 to start serializing from.
756
757 If the bnode_border feature is set, the DOT serializer uses it as the
758 bnode border colour.
759
760 If the bnode_fill feature is set, the DOT serializer uses it as the
761 bnode fill colour.
762
763 If the json_callback feature is set, the JSON serializers use it as the
764 name of the callback to wrap the outer JSON object.
765
766 If the json_extra_data feature is set, the JSON serializers use it as
767 extra data inside the outer JSON object.
768
769 If the literal_border feature is set, the DOT serializer uses it as the
770 literal border colour.
771
772 If the literal_fill feature is set, the DOT serializer uses it as the
773 literal fill colour.
774
775 If the resource_border feature is set, the DOT serializer uses it as
776 the resource border colour.
777
778 If the resource_fill feature is set, the DOT serializer uses it as the
779 resource fill colour.
780
781 If the rss_triples feature is set to the string "rdf-xml" for the
782 rss-1.0 serializer or "atom-triples" for the atom serializer, it writes
783 extra rdf triples into the serialized output.
784
785 If the atom_entry_uri feature is set to a URI string, it is used to
786 trigger generation of an atom entry document for the atom serializer.
787
788 int raptor_serializer_get_feature(raptor_serializer* serializer, rap‐
789 tor_feature feature)
790 Get serializer features, the allowed feature values are avail‐
791 able
792
794 int raptor_serializers_enumerate(const unsigned int counter, const char
795 **name, const char **label, const char **mime_type, const unsigned char
796 **uri_string)
797 Return the serializer name/label for a serializer with a given
798 integer counter, returning non-zero if no such parser at that
799 offset exists. The counter should start from 0 and be incre‐
800 mented by 1 until the function returns non-zero.
801
802 int raptor_serializer_syntax_name_check(const char *name)
803 Check name is a known serializer syntax name.
804
806 Raptor has a raptor_uri class must be used for manipulating and passing
807 URI references. The default internal implementation uses char* strings
808 for URIs, manipulating them and constructing them. This URI implemen‐
809 tation can be replaced by any other that provides the equivalent func‐
810 tionality, using the raptor_uri_set_handler function.
811
813 There a several constructors for raptor_uri to build them from char*
814 strings and existing raptor_uri objects.
815
816 raptor_uri* raptor_new_uri(const unsigned char* uri_string)
817 Create a raptor URI from a string URI-reference uri_string.
818
819 raptor_uri* raptor_new_uri_from_uri_local_name(raptor_uri* uri, const
820 unsigned char* local_name)
821 Create a raptor URI from a string URI-reference local_name rela‐
822 tive to an existing URI-reference. This performs concatenation
823 of the local_name to the uri and not relative URI resolution,
824 which is done by the raptor_new_uri_relative_to_base construc‐
825 tor.
826
827 raptor_uri* raptor_new_uri_relative_to_base(raptor_uri* base_uri, const
828 unsigned char* uri_string)
829 Create a raptor URI from a string URI-reference uri_string using
830 relative URI resolution to the base_uri.
831
832 raptor_uri* raptor_new_uri_from_id(raptor_uri* base_uri, const unsigned
833 char* id)
834 Create a raptor URI from a string RDF ID id concatenated to the
835 base_uri base URI.
836
837 raptor_uri* raptor_new_uri_for_rdf_concept(const char* name)
838 Create a raptor URI for the RDF namespace concept name.
839
840 raptor_uri* raptor_new_uri_for_xmlbase(raptor_uri* old_uri))
841 Create a raptor URI suitable for use with xml:base (throw away
842 fragment)
843
845 void raptor_free_uri(raptor_uri* uri)
846 Destroy a raptor URI object.
847
849 int raptor_uri_equals(raptor_uri* uri1, raptor_uri* uri2)
850 Return non-zero if the given URIs are equal.
851
852 raptor_uri* raptor_uri_copy(raptor_uri* uri)
853 Return a copy of the given raptor URI uri.
854
855 unsigned char* raptor_uri_as_counted_string(raptor_uri *uri, size_t*
856 len_p)
857
858 unsigned char* raptor_uri_as_string(raptor_uri* uri)
859 Return a shared pointer to a string representation of the given
860 raptor URI uri. This string is shared and must not be freed
861 (otherwise see the raptor_uri_to_* methods below). If rap‐
862 tor_uri_as_counted_string is used, the length of the returned
863 string is stored in *len_p if not NULL.
864
865 unsigned char* raptor_uri_to_counted_string(raptor_uri *uri, size_t
866 *len_p)
867
868 unsigned char* raptor_uri_to_string(raptor_uri *uri)
869 Return a to a newly alloced string representation of the given
870 raptor URI uri. This string must be freed by the caller using
871 raptor_free_memory. If raptor_uri_to_counted_string is used,
872 the length of the returned string is stored in *len_p if not
873 NULL.
874
875 unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri
876 *base_uri, raptor_uri *reference_uri, size_t *length_p)
877
878 unsigned char* raptor_uri_to_relative_uri_string(raptor_uri *base_uri,
879 raptor_uri *reference_uri)
880 Return a new relative URI string of a URI reference_uri against
881 a base URI base_uri. The returned string must be freed with
882 raptor_free_memory. If raptor_uri_to_relative_counted_string is
883 used, the length of the returned string is stored in *len_p if
884 not NULL.
885
886 void raptor_uri_print(const raptor_uri* uri, FILE *stream)
887 Print URI uri to the file handle stream.
888
889 int raptor_iostream_write_uri(raptor_iostream* iostr, raptor_uri* uri)
890 Write the raptor_uri uri to the iostream ostr.
891
893 void raptor_uri_resolve_uri_reference (const unsigned char* base_uri,
894 const unsigned char* reference_uri, char unsigned* buffer, size_t
895 length)
896 This is a standalone function that resolves the relative URI
897 reference_uri against the base URI base_uri according to the URI
898 resolution rules in RFC2396. The resulting URI is stored in
899 buffer which is of length bytes. If this is too small, no work
900 will be done.
901
902 char *raptor_uri_filename_to_uri_string(const unsigned char* filename)
903 This is a standalone function that turns a local filename (Win‐
904 dows or Unix style as appropriate for platform) into a URI
905 string (file).
906 The returned string must be freed by the caller. Some systems
907 require memory allocated in a library to be deallocated inside
908 that library in which case raptor_free_memory may be used.
909
910 char *raptor_uri_uri_string_to_filename(const unsigned char*
911 uri_string)
912
913 char *raptor_uri_uri_string_to_filename(const unsigned char*
914 uri_string, unsigned char **fragment_p)
915 These are standalone functions that turn a URI string that rep‐
916 resents a local filename (file:) into a filename, with optional
917 URI fragment. If fragment_p is not NULL it points to the loca‐
918 tion to store a newly allocated string containing the fragment.
919 The returned strings must be freed by the caller. Some systems
920 require memory allocated in a library to be deallocated inside
921 that library in which case raptor_free_memory may be used.
922
923 int raptor_uri_is_file_uri(const unsigned char* uri_string)
924 DEPRECATED in 1.4.9. Returns non-zero if the given URI string
925 represents a filename. Use raptor_uri_uri_string_is_file_uri in
926 preference.
927
928 int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string)
929 Returns non-zero if the given URI string represents a filename.
930
932 void raptor_uri_set_handler(const raptor_uri_handler *handler, void
933 *context)
934 Change the URI class implementation to the functions provided by
935 the handler URI implementation. The context user data is passed
936 in to the handler URI implementation calls.
937
938 void raptor_uri_get_handler(raptor_uri_handler **handler, void **con‐
939 text)
940 Return the current raptor URI class implementation handler and
941 context
942
943
945 This is a small wrapper class around existing WWW libraries in order to
946 provide HTTP GET or better URI retrieval for Raptor. It is not
947 intended to be a general purpose WWW retrieval interface.
948
950 void raptor_www_init(void)
951
952 void raptor_www_finish(void)
953 Initialise or terminate the raptor_www infrastructure. rap‐
954 tor_www_init and raptor_finish are called by raptor_init and
955 raptor_finish respecitively, otherwise must be called once each.
956
957 NOTE Several of the WWW library implementations require once-only
958 initialisation and termination functions to be called, however
959 raptor cannot determine whether this is already done before the
960 library is initialised in raptor_www_init or terminated in rap‐
961 tor_www_finish, so always performs it. This can be changed by
962 raptor_www_no_www_library_init_finish.
963
964 void raptor_www_no_www_library_init_finish(void)
965 If this is called before raptor_www_init, it will not call the
966 underlying WWW library global initialise or terminate functions.
967 The application code must perform both operations.
968
969 For example with curl, after this function is called, neither
970 curl_global_init nor curl_global_cleanup will be called during
971 raptor_www_init or raptor_www_finish respectively.
972
974 raptor_www *raptor_www_new(void)
975
976 raptor_www *raptor_www_new_with_connection(void* connection)
977 Create a raptor WWW object capable of URI retrieval. If connec‐
978 tion is given, it must match the connection object of the under‐
979 lying WWW implementation. At present, this is only for libcurl,
980 and allows you to re-use an existing curl handle, or use one
981 which has been set up with some desired qualities.
982
984 void raptor_www_free(raptor_www *www)
985 Destroy a raptor WWW object.
986
988 void raptor_www_set_user_agent(raptor_www *www, const char *user_agent)
989 Set the HTTP User-Agent header value.
990
991 int raptor_www_set_http_cache_control(raptor_www* www, const char*
992 cache_control)
993 Set the HTTP Cache-Control header value.
994
995 void raptor_www_set_proxy(raptor_www *www, const char *proxy)
996 Set the HTTP proxy - usually a string of the form
997 http://server:port
998
999 raptor_www_set_write_bytes_handler(raptor_www *www, rap‐
1000 tor_www_write_bytes_handler handler, void *user_data)
1001 Set the handler to receive bytes written by the raptor_www
1002 implementation.
1003
1004 void raptor_www_set_content_type_handler(raptor_www *www, rap‐
1005 tor_www_content_type_handler handler, void *user_data)
1006 Set the handler to receive the HTTP Content-Type value, when/if
1007 discovered during retrieval by the raptor_www implementation.
1008
1009 void raptor_www_set_http_accept(raptor_www *www, const char *value)
1010 Set the WWW HTTP Accept: header to value. If value is NULL, an
1011 empty header is sent.
1012
1013 void raptor_www_set_error_handler(raptor_www *www, raptor_message_han‐
1014 dler error_handler, void *error_data)
1015 Set the error handler routine for the raptor_www class. This
1016 takes the same arguments as the raptor_parser error, warning
1017 handler methods.
1018
1019 void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func
1020 filter, void* user_data)
1021 Set the URI filter function filter for URIs retrieved by the
1022 raptor_www object.
1023
1024 void* raptor_www_get_connection(raptor_www *www)
1025 Return the underlying WWW library connection object. For exam‐
1026 ple, for libcurl this is the curl_handle.
1027
1028 void raptor_www_set_connection_timeout(raptor_www* www, int timeout)
1029 Set the WWW connection timeout in seconds.
1030
1031 raptor_uri* raptor_www_get_final_uri(raptor_www* www)
1032 Get the final URI from a WWW retrieval, which may include redi‐
1033 rections.
1034
1036 int raptor_www_fetch(raptor_www *www, raptor_uri *uri)
1037 Retrieve the given URL, returning non zero on failure.
1038
1039 int raptor_www_fetch_to_string(raptor_www *www, raptor_uri *uri, void
1040 **string_p, size_t *length_p, void *(*malloc_handler)(size_t size))
1041 Retrieve the given URL to a string. string_p must point to a
1042 void* pointer that will be used to store the newly allocated
1043 string. length_p if not NULL, it will be used to store the
1044 length of the new string.
1045
1046 void raptor_www_abort(raptor_www *www, const char *reason)
1047 Abort an ongoing raptor WWW operation. Typically used within one
1048 of the raptor WWW handlers.
1049
1051 This is a class for handling XML QNames consisting of the pair of (a
1052 URI from a namespace, a local name) along with an optional value --
1053 useful for XML attributes. This is used with the raptor_names‐
1054 pace_stack and raptor_namespace classes to handle a stack of rap‐
1055 tor_namespace that build on raptor_qname.
1056
1058 There are two constructors for raptor_qname to build qnames with
1059 optional values on a stack of names.
1060
1061 raptor_qname* raptor_new_qname(raptor_namespace_stack *nstack, const
1062 unsigned char *name, const unsigned char *value, raptor_simple_mes‐
1063 sage_handler error_handler, void *error_data)
1064 Create a raptor QName name (a possibly :-separated name) with
1065 name to be resolved against the given nstack namespace stack.
1066 An optional value can be given, and if there is an error, the
1067 error_handler and error_data will be used to invoke the call‐
1068 back.
1069
1070 raptor_qname* raptor_new_qname_from_namespace_local_name (raptor_names‐
1071 pace *ns, const unsigned char *local_name, const unsigned char *value)
1072 Create a raptor QName using the namespace name of the rap‐
1073 tor_namespace ns and the local name local_name, along with
1074 optional value value. Errors are reported using the error han‐
1075 dling and data of the namespace.
1076
1077 raptor_qname* raptor_qname_copy(raptor_qname *qname)
1078 Create a raptor QName from an existing one, returning NULL on
1079 failure.
1080
1082 void raptor_free_qname(raptor_qname* name)
1083 Destroy a raptor qname object.
1084
1086 int raptor_qname_equal(raptor_qname* name1, raptor_qname *name2)
1087 Return non-zero if the given QNames are equal.
1088
1089 int raptor_iostream_write_qname(raptor_iostream* iostr, raptor_qname
1090 *qname)
1091 Write the raptor_qname qname to the iostream ostr.
1092
1093 const unsigned char* raptor_qname_get_local_name(raptor_qname* name)
1094 Get the local name of the QName.
1095
1096 const unsigned char* raptor_qname_get_value(raptor_qname* name)
1097 Get the value of the QName for an XML attribute QName.
1098
1099 const unsigned char* raptor_qname_get_counted_value(raptor_qname* name,
1100 size_t* length_p)
1101 Get the value fo the QName along with the length (if length_p is
1102 not NULL) for an XML attribute QName.
1103
1104 unsigned char* raptor_qname_to_counted_name(raptor_qname* qname,
1105 size_t* length_p)
1106 Get the formatted QName as a newly allocated counted string (if
1107 length_p is not NULL).
1108
1110 raptor_uri* raptor_qname_string_to_uri(raptor_namespace_stack *nstack,
1111 const unsigned char *name, size_t name_len, raptor_simple_message_han‐
1112 dler error_handler, void *error_data)
1113 Return the URI corresponding to the QName according to the RDF
1114 method; concatenating the namespace's name (URI) with the local
1115 name. Takes the same arguments as raptor_new_qname but does not
1116 create a raptor_qname object.
1117
1118 raptor_namespace* raptor_qname_get_namespace(raptor_qname* name)
1119 Return the raptor_namespace used by the QName. Will never be
1120 NULL even for the default namespace in which case the URI of the
1121 returned namespace object will be NULL.
1122
1124 An XML namespace class - each entry is on a stack and consists of a
1125 name (URI) and prefix. The prefix or the name but not both may be
1126 empty. If the prefix is empty, it defines the default prefix. If the
1127 name is empty, it undefines the given prefix.
1128
1130 raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack,
1131 const unsigned char *prefix, const unsigned char *ns_uri_string, int
1132 depth)
1133
1134 raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack
1135 *nstack, const unsigned char *prefix, raptor_uri* ns_uri, int depth)
1136 Create a new raptor_namespace object on the given namespace
1137 stack nstack with prefix prefix and namespace name either from
1138 URI string ns_uri_string or from copying URI ns_uri.
1139
1140 If prefix is NULL, it defines the URI for the default namespace prefix.
1141 If the namespace name (ns_uri_string or ns_uri) is NULL, it undefines
1142 the given prefix in the current scope. Both prefix and URI may be NULL
1143 to undefine the default namespace. depth signifies the position of the
1144 namespace on the stack; 0 is the bottom of the stack and generally the
1145 first depth for user namespace declarations.
1146
1147 Namespaces declared on the same depth (such as on the same XML element,
1148 typically) can be handily freed with raptor_namespaces_end_for_depth
1149 method on the namespace stack class.
1150
1152 void raptor_free_namespace(raptor_namespace *ns)
1153 Destroy a raptor namespace object.
1154
1156 raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns)
1157 Return the namespace name (URI) of the namespace.
1158
1159 const unsigned char* raptor_namespace_get_prefix(const raptor_namespace
1160 *ns)
1161 Return the prefix of the namespace.
1162
1163 const unsigned char* raptor_namespace_get_counted_prefix(const rap‐
1164 tor_namespace* ns, size_t* length_p)
1165 Return the prefix of the namespace as a string with optional
1166 count stored in the variable address length_p if it is not NULL.
1167
1168 unsigned char *raptor_namespaces_format(const raptor_namespace *ns,
1169 size_t *length_p)
1170 Format the namespace as a string and return it as a new string,
1171 returning the length of the resulting string in length_p if it
1172 is not NULL. The string format is suitable for emitting in XML
1173 to declare the namespace.
1174
1175 int raptor_iostream_write_namespace(raptor_iostream* iostr, rap‐
1176 tor_namespace *ns)
1177 Write a formatted namespace declaration like xmlns... to an
1178 iostream iostr.
1179
1181 int raptor_namespace_copy(raptor_namespace_stack *nstack, raptor_names‐
1182 pace *ns, int new_depth)
1183 Copy the namespace from the current stack to the new one, nstack
1184 at depth new_depth.
1185
1186 int raptor_new_namespace_parts_from_string(unsigned char *string,
1187 unsigned char **prefix, unsigned char **uri_string)
1188 Parse string with an XML-style namespace declaration like
1189 xmlns="", xmlns="uri", xmlns:prefix="" or xmlns:prefix="uri"
1190 into the strings pointed to by prefix string and a uri_string.
1191 Empty prefixes or namespace names return NULL pointers.
1192 Returned strings must be freed by the caller using rap‐
1193 tor_free_memory.
1194
1196 A stack of raptor_namespace objects where the namespaces on top of the
1197 stack have wider scope and override earlier (lower) namespace declara‐
1198 tions. Intended to match the XML namespace declaring semantics using
1199 xmlns attributes.
1200
1202 raptor_namespace_stack* raptor_new_namespaces(raptor_uri_handler
1203 *uri_handler, void *uri_context, raptor_simple_message_handler
1204 error_handler, void *error_data, int defaults)
1205
1206 int raptor_namespaces_init(raptor_namespace_stack *nstack, rap‐
1207 tor_uri_handler *handler, void *context, raptor_simple_message_handler
1208 error_handler, void *error_data, int defaults)
1209 Create or initialise a new raptor_namespace_stack object with
1210 the given URI and error handlers. raptor_namespaces_new allo‐
1211 cates new memory for the namespace stack and raptor_names‐
1212 paces_init initialises an existing declared nstack, which could
1213 be statically allocated. Note that raptor_uri_get_handler can
1214 be useful to return the current raptor URI handler/context. The
1215 defaults argument describes which default namespaces are
1216 declared in the empty stack. At present, 0 is none, 1 for just
1217 the XML namespace and 2 is for a typical set of namespaces used
1218 for RDF, RDFS, Dublin Core, OWL, ... that may vary over time.
1219
1220 In versions 1.4.16 or newer this returns an integer result,
1221 non-0 on failure.
1222
1224 void raptor_free_namespaces(raptor_namespace_stack *nstack)
1225 Destroy a namespace stack object, freeing the nstack (goes with
1226 raptor_new_namespaces).
1227
1228 void raptor_namespaces_clear(raptor_namespace_stack *nstack)
1229 Clear a statically allocated namespace stack; does not free the
1230 nstack. (goes with raptor_namespaces_init).
1231
1233 void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack,
1234 raptor_namespace *nspace)
1235 Start the given nspace on the stack, at the depth already
1236 defined.
1237
1238 int raptor_namespaces_start_namespace_full(raptor_namespace_stack
1239 *nstack, const unsigned char *prefix, const unsigned char *nspace, int
1240 depth)
1241 Create a new raptor_namespace and start it on the stack. See
1242 raptor_new_namespace for the meaning of the argumens.
1243
1244 void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack,
1245 int depth)
1246 End (and free) all namespaces on the stack at the given depth.
1247
1248 raptor_namespace* raptor_namespaces_get_default_namespace (rap‐
1249 tor_namespace_stack *nstack)
1250 Return the current default raptor_namespace of the namespace
1251 stack or NULL if there is none.
1252
1253 raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_names‐
1254 pace_stack *nstack, raptor_uri *ns_uri)
1255 Find the first namespace on the stack with the given uri ns_uri
1256 or NULL if there is none.
1257
1258 raptor_namespace *raptor_namespaces_find_namespace_by_uri(raptor_names‐
1259 pace_stack *nstack, const unsigned char *prefix, int prefix_length)
1260 Find the first namespace on the stack with the given namespace
1261 prefix or NULL if there is none.
1262
1263 int raptor_namespaces_namespace_in_scope(raptor_namespace_stack
1264 *nstack, const raptor_namespace *nspace)
1265 Return non-zero if the raptor_namespace nspace is declared on
1266 the stack; i.e. in scope if this is a stack of XML namespaces.
1267
1269 raptor_qname* raptor_namespaces_qname_from_uri(raptor_namespace_stack*
1270 nstack, raptor_uri* uri, int xml_version)
1271 Create a raptor QName from the URI uri if the URI is squal one
1272 of the namespace URIs on the namespace stack nstack URIs con‐
1273 catenated to a legal XML name for the given XML version. URIs
1274 are created and errors are reported using the namespace stack
1275 fields. Fails if it cannot be legally described with any of the
1276 namespaces.
1277
1279 A class for ordered sequences of items, adding at either end of the
1280 sequence. The method names should be familiar to Perl users.
1281
1283 raptor_sequence* raptor_new_sequence(raptor_sequence_free_handler*
1284 free_handler, raptor_sequence_print_handler* print_handler)
1285 Create a new empty sequence, with optional handler for freeing
1286 elements (as used by raptor_free_sequence and printing out ele‐
1287 ments (used by raptor_sequence_print).
1288
1290 void raptor_free_sequence(raptor_sequence* seq)
1291 Destoy a sequence object, freeing any items if the free handler
1292 was defined in the constructor.
1293
1295 int raptor_sequence_size(raptor_sequence* seq)
1296 Return the number of items in the sequence.
1297
1298 int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data)
1299 Set the sequence item at index idx to the value data, extending
1300 it if necessary.
1301
1302 int raptor_sequence_push(raptor_sequence* seq, void *data)
1303 Add item data to the end of the sequence.
1304
1305 int raptor_sequence_shift(raptor_sequence* seq, void *data)
1306 Add item data to the start of the sequence.
1307
1308 void* raptor_sequence_get_at(raptor_sequence* seq, int idx)
1309 Get the sequence item at index idx or NULL if no such index
1310 exists.
1311
1312 void* raptor_sequence_pop(raptor_sequence* seq)
1313 Remove and return an item from the end of the sequence, or NULL
1314 if is empty.
1315
1316 void* raptor_sequence_unshift(raptor_sequence* seq)
1317 Remove and return an item from the start of the sequence, or
1318 NULL if is empty.
1319
1320 void raptor_sequence_sort(raptor_sequence* seq, int(*compare)(const
1321 void *, const void *))
1322 Sort the sequence using the given comparison function compare
1323 which is passed to qsort(3) internally.
1324
1325 int raptor_compare_strings(const void *a, const void *b)
1326 Helper function useful with raptor_sequence_sort.
1327
1328 void raptor_sequence_set_print_handler(raptor_sequence *seq, rap‐
1329 tor_sequence_print_handler *print_handler)
1330 Set the print handler for the sequence, an alternative to set‐
1331 ting it in the constructor.
1332
1333 void raptor_sequence_print_string(char *data, FILE *fh)
1334 Helper print handler function useful for printing out sequences
1335 of strings.
1336
1337 void raptor_sequence_print_uri(char *data, FILE *fh)
1338 Helper print handler function useful for printing out sequences
1339 of raptor_uri* objects.
1340
1341 void raptor_sequence_print(raptor_sequence* seq, FILE* fh)
1342 Print out the sequence in a debug format to the given file han‐
1343 dler fh. NOTE: The exact format is not guaranteed to remain the
1344 same between releases.
1345
1346 int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src)
1347 Join two sequences moving all items from sequence src to the end
1348 of sequence dest. After this operation, sequence src will be
1349 empty (zero size) but will have the same item capacity as
1350 before.
1351
1352 void* raptor_sequence_delete_at(raptor_sequence* seq, int idx)
1353 Remove an item from position idx in the sequence, returning it.
1354
1356 A class for growing strings, small chunks at a time.
1357
1359 raptor_stringbuffer* raptor_new_stringbuffer(void)
1360 Create a new stringbuffer.
1361
1363 void raptor_free_stringbuffer(raptor_stringbuffer* stringbuffer)
1364 Destroy a stringbuffer.
1365
1367 int raptor_stringbuffer_append_counted_string(raptor_stringbuffer*
1368 stringbuffer, const unsigned char *string, size_t length, int do_copy)
1369 Append a string of length bytes to a stringbuffer, copying it
1370 only if do_copy is non-0.
1371
1372 int raptor_stringbuffer_append_string(raptor_stringbuffer* string‐
1373 buffer, const unsigned char* string, int do_copy)
1374 Append a string to a stringbuffer, copying it only if do_copy is
1375 non-0.
1376
1377 int raptor_stringbuffer_append_decimal(raptor_stringbuffer* string‐
1378 buffer, int integer)
1379 Append a formatted decimal integer to a stringbuffer.
1380
1381 int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer*
1382 stringbuffer, raptor_stringbuffer* append)
1383 Append a stringbuffer append to a stringbuffer. The append
1384 stringbuffer is emptied but not destroyed.
1385
1386 int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer*
1387 stringbuffer, const unsigned char* string, size_t length, int do_copy)
1388 Prepend a string of length bytes to the start of a stringbuffer,
1389 copying it only if do_copy is non-0.
1390
1391 int raptor_stringbuffer_prepend_string(raptor_stringbuffer* string‐
1392 buffer, const unsigned char* string, int do_copy)
1393 Prepend a string to the start of a stringbuffer, copying it only
1394 if do_copy is non-0.
1395
1396 unsigned char * raptor_stringbuffer_as_string(raptor_stringbuffer*
1397 stringbuffer)
1398 Return the stringbuffer as a single string. The string is
1399 shared and should be copied if needed.
1400
1401 size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer)
1402 Return the length of the stringbuffer.
1403
1404 int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* string‐
1405 buffer, unsigned char *string, size_t length)
1406 Copy the stringbuffer into a single string buffer string of size
1407 length. Returns non-0 on failure.
1408
1410 This class provides an I/O stream that can write to filenames, FILE*,
1411 strings and user-defined output via callbacks.
1412
1414 raptor_iostream* raptor_new_iostream_from_handler2(void* context, const
1415 raptor_iostream_handler2 *handler)
1416 Create a new raptor read or write iostream from a user-defined
1417 raptor_iostream_handler2 handler that is called with the passed-
1418 in context for the write operations.
1419
1420 raptor_iostream* raptor_new_iostream_from_handler(void* context, const
1421 raptor_iostream_handler *handler)
1422 DEPRECATED in 1.4.17 - use raptor_new_iostream_from_handler2()
1423 with the new handler format. Create a new raptor read iostream
1424 from a user-defined raptor_iostream_handler handler that is
1425 called with the passed-in context for the write operations.
1426
1427 raptor_iostream* raptor_new_iostream_to_sink(void)
1428 Create a new raptor write iostream that discards all written
1429 output.
1430
1431 raptor_iostream* raptor_new_iostream_to_filename(const char *filename)
1432 Create a new raptor write iostream that creates and writes to a
1433 new file filename.
1434
1435 raptor_iostream* raptor_new_iostream_to_file_handle(FILE *handle)
1436 Create a new raptor write iostream that creates and writes to an
1437 existing, already opened, C Standard I/O handle FILE* handle.
1438
1439 raptor_iostream* raptor_new_iostream_to_string(void **string_p, size_t
1440 *length_p, void *(*malloc_handler)(size_t size))
1441 Create a new raptor write iostream which creates a new string
1442 once raptor_free_iostream is called. The new string pointer is
1443 written in string, the length in length_p (if not NULL) and the
1444 memory allocation is made using the malloc_handler, or if NULL,
1445 raptor's default memory allocator.
1446
1447 raptor_iostream* raptor_new_iostream_from_sink(void)
1448 Create a new raptor read iostream that is immediately finished
1449 and returns end of file.
1450
1451 raptor_iostream* raptor_new_iostream_from_filename(const char *file‐
1452 name)
1453 Create a new raptor read iostream from an existing file file‐
1454 name.
1455
1456 raptor_iostream* raptor_new_iostream_from_file_handle(FILE *handle)
1457 Create a new raptor read iostream from an already opened, C
1458 Standard I/O handle FILE* handler.
1459
1460 raptor_iostream* raptor_new_iostream_from_string(void *string, size_t
1461 length)
1462 Create a new raptor read iostream reading from an existing
1463 string of length bytes.
1464
1466 void raptor_free_iostream(raptor_iostream *iostr)
1467 Destroy a Raptor iostream object.
1468
1470 int raptor_iostream_write_bytes(raptor_iostream *iostr, const void
1471 *ptr, size_t size, size_t nmemb)
1472 Write a counted set of elements to an iostream. Inmemb is the
1473 count of elements of size size, starting at memory ptr. Similar
1474 to fwrite(3) and write(2).
1475
1476 int raptor_iostream_write_byte(raptor_iostream *iostr, const int byte)
1477 Write a single byte an iostream. Similar to fputc(3).
1478
1479 void raptor_iostream_write_end(raptor_iostream *iostr)
1480 Finish writing to an iostream.
1481
1482 int raptor_iostream_write_string(raptor_iostream *iostr, const void
1483 *string)
1484 Write a NUL-terminated string to an iostream. Similar to
1485 fputs(3).
1486
1487 int raptor_iostream_write_counted_string(raptor_iostream *iostr, const
1488 void *string, size_t len)
1489 Write a string of length len to an iostream.
1490
1491 unsigned long raptor_iostream_tell(raptor_iostream *iostr)
1492 Return the byte offset into the iostream.
1493
1494 size_t raptor_iostream_get_bytes_written_count(raptor_iostream *iostr)
1495 DEPRECATED in 1.4.17 for raptor_iostream_tell(). Return the
1496 number of bytes written so far to the iostream.
1497
1498 int raptor_iostream_write_decimal(raptor_iostream *iostr, int integer)
1499 Write a decimal formatted integer integer to the iostream.
1500
1501 int raptor_iostream_format_hexadecimal(raptor_iostream *iostr, unsigned
1502 int integer, int width)
1503 Write a hexadecimal formatted unsigned integer to the iostream,
1504 left-padded with '0's to width columns.
1505
1506 int raptor_iostream_write_stringbuffer(raptor_iostream* iostr, rap‐
1507 tor_stringbuffer *sb)
1508 Write the stringbuffer to an iostream iostr.
1509
1510 int raptor_iostream_read_bytes(raptor_iostream* iostr, void *ptr,
1511 size_t size, size_t nmemb)
1512 Read bytes from the iostream into buffer ptr up to nmemb ele‐
1513 ments of size size.
1514
1515 int raptor_iostream_read_eof(raptor_iostream *iostr)
1516 Return non-0 if the iostream is finished.
1517
1519 This class provides the functionality to generate SAX2 events from
1520 parsing XML content, including XML namespace support.
1521
1523 raptor_sax2* raptor_new_sax2(void *user_data, raptor_error_handlers*
1524 error_handlers)
1525 Create a new SAX2 XML reader with the given error handler
1526 object.
1527
1529 void raptor_free_sax2(raptor_sax2 *sax2)
1530 Destroy a SAX2 XML reader object.
1531
1533 void raptor_sax2_set_start_element_handler(raptor_sax2 *sax2, rap‐
1534 tor_sax2_start_element_handler handler)
1535 Set the SAX2 start element handler.
1536
1537 void raptor_sax2_set_end_element_handler(raptor_sax2 *sax2, rap‐
1538 tor_sax2_end_element_handler handler)
1539 Set the SAX2 end element handler.
1540
1541 void raptor_sax2_set_characters_handler(raptor_sax2 *sax2, rap‐
1542 tor_sax2_characters_handler handler)
1543 Set the SAX2 character data element handler.
1544
1545 void raptor_sax2_set_cdata_handler(raptor_sax2 *sax2, rap‐
1546 tor_sax2_cdata_handler handler)
1547 Set the SAX2 CDATA section element handler.
1548
1549 void raptor_sax2_set_comment_handler(raptor_sax2 *sax2, rap‐
1550 tor_sax2_comment_handler handler)
1551 Set the SAX2 XML comment handler.
1552
1553 void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2 *sax2,
1554 raptor_sax2_unparsed_entity_decl_handler handler)
1555 Set the SAX2 XML unparsed entity declaration handler.
1556
1557 void raptor_sax2_set_external_entity_ref_handler(raptor_sax2 *sax2,
1558 raptor_sax2_external_entity_ref_handler handler)
1559 Set the SAX2 XML external entity reference handler.
1560
1561 void raptor_sax2_set_namespace_handler(raptor_sax2 *sax2, raptor_names‐
1562 pace_handler handler)
1563 Set the SAX2 XML namespace declaration handler when an XML
1564 namespace is declared.
1565
1567 void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri)
1568 Start a SAX2 parse of XML content with the base URI uri.
1569
1570 int raptor_sax2_parse_chunk(raptor_sax2 *sax2, const unsigned char
1571 *buffer, size_t len, int is_end)
1572 Parse the XML content in buffer of size len returning SAX2
1573 events via handlers. If is_end is non-zero, it indicates the
1574 end of the parsing. This method can only be called after rap‐
1575 tor_sax2_parse_start().
1576
1578 const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2
1579 *sax2)
1580 Get the current in-scope XML language (xml:lang) value.
1581
1582 raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2 *sax2)
1583 Get the current in-scope Base URI (xml:base or document or pro‐
1584 tocol) value.
1585
1587 This class provides an XML element that can be used with the XML Writer
1588 Class to generate XML documents.
1589
1591 raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const
1592 unsigned char* xml_language, raptor_uri* xml_base)
1593 Create a new XML element with the element name name in the con‐
1594 text of xml:lang xml_language and base URI xml_base.
1595
1596 raptor_xml_element* raptor_new_xml_element_from_names‐
1597 pace_local_name(raptor_namespace *ns, const unsigned char *name, const
1598 unsigned char* xml_language, raptor_uri* xml_base
1599 Create a new XML element based on the given XML namespace and
1600 localname in the context of xml:lang xml_language and base URI
1601 xml_base.
1602
1604 void raptor_free_xml_element(raptor_xml_element *element)
1605 Destroy a XML element object.
1606
1608 raptor_qname* raptor_xml_element_get_name(raptor_xml_element* xml_ele‐
1609 ment)
1610 Get the XML element QName of XML element xml_element.
1611
1612 void raptor_xml_element_set_attributes(raptor_xml_element* xml_element,
1613 raptor_qname **attributes, int count)
1614 Set the attributes on XML element xml_element to the array of
1615 QNames in array attributes of size count.
1616
1617 raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element*
1618 xml_element)
1619 Get the attributes of an XML element xml_element as an array of
1620 QNames. As set by void raptor_xml_element_set_attributes.
1621
1622 int raptor_xml_element_get_attributes_count(raptor_xml_element*
1623 xml_element)
1624 Get the number of attributes of an XML element xml_element as
1625 set by void raptor_xml_element_set_attributes.
1626
1627 int raptor_xml_element_declare_namespace(raptor_xml_element* xml_ele‐
1628 ment, raptor_namespace* nspace)
1629 Declare an XML namespace nspace expliclitly on XML element
1630 xml_element. Namespaces used in the element or attribute names
1631 are automatically declared, this method allows additional ones
1632 to be done.
1633
1634 int raptor_xml_element_is_empty(raptor_xml_element* xml_element)
1635 Return non-0 if the XML element is empty.
1636
1637 int raptor_iostream_write_xml_element(raptor_iostream* iostr, rap‐
1638 tor_xml_element *element, raptor_namespace_stack* nstack, int is_empty,
1639 int is_end, raptor_simple_message_handler error_handler, void*
1640 error_data, int depth)
1641 Write a XML element xml_element to iostream ostr. This is done
1642 in context of an XML namespace stack nstack and at depth depth
1643 in the stack (see Namespace class constructors).
1644
1645 The element may be an empty element if is_empty is non-zero or
1646 may be a close element if is_end is non-zero (else is a start
1647 element). The error_handler method along with error_data allow
1648 error reporting to be given.
1649
1650 const unsigned char* raptor_xml_element_get_language(raptor_xml_ele‐
1651 ment* xml_element)
1652 Get the xml:lang language of the XML element.
1653
1655 This class provides the functionality to generate simple XML documents
1656 consisting of elements with attributes, character data and comments.
1657 The documents can be written to an iostream.
1658
1660 raptor_xml_writer* raptor_new_xml_writer(raptor_namespace_stack*
1661 nstack, raptor_uri_handler* uri_handler, void* uri_context, rap‐
1662 tor_iostream* iostr, raptor_simple_message_handler error_handler, void
1663 *error_data, int canonicalize)
1664 Create a new XML Writer writing to iostream iostr. The
1665 error_handler method along with error_data allow error reporting
1666 to be given. nstack is either an existing namespace stack to be
1667 used or if NULL, a new one with only the XML namespace defined
1668 is created. Note that raptor_uri_get_handler can be useful to
1669 return the current raptor URI handler/context. canonicalize is
1670 currently unused and should be set to 1 but may allow non-canon‐
1671 ical XML writing to be allowed in future.
1672
1674 void raptor_free_xml_writer(raptor_xml_writer* xml_writer)
1675 Destroy a XML Writer object.
1676
1678 void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer,
1679 raptor_xml_element *element)
1680 Write XML element element as an empty element (no element con‐
1681 tent) to the XML Writer xml_writer.
1682
1683 void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer,
1684 raptor_xml_element *element)
1685 Write a start element along with an attributes and namespace
1686 declarations for XML element element to the XML Writer
1687 xml_writer.
1688
1689 void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, rap‐
1690 tor_xml_element *element)
1691 Write an end element form for XML element element to the XML
1692 Writer xml_writer.
1693
1694 void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const
1695 unsigned char *str)
1696 Write XML character data in str to the XML Writer xml_writer.
1697 The characters in str will be XML escaped.
1698
1699 void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer,
1700 const unsigned char* str, unsigned int length)
1701 Write XML character data in str of length length to the XML
1702 Writer xml_writer. The characters in str will be XML escaped.
1703
1704 void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const
1705 unsigned char* str)
1706 Write character data in str length to the XML Writer xml_writer
1707 without XML escaping.
1708
1709 void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const
1710 unsigned char* str, unsigned int length)
1711 Write character data in str of length length to the XML Writer
1712 xml_writer without XML escaping.
1713
1714 void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const
1715 unsigned char* str)
1716 Write an XML comment in str to the XML Writer xml_writer.
1717
1718 void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer,
1719 const unsigned char* str, unsigned int length)
1720 Write an XML comment in str of length length to the XML Writer
1721 xml_writer.
1722
1723 int raptor_xml_writer_features_enumerate(const raptor_feature feature,
1724 const char **name, raptor_uri **uri, const char **label)
1725 Return the name, URI, string label (all optional) for an XML
1726 write feature, returning non-zero if no such feature exists.
1727
1728 Raptor features have URIs that are constructed from the URI http://fea‐
1729 ture.librdf.org/raptor- and the name so for example feature scanForRDF
1730 has URI http://feature.librdf.org/raptor-scanForRDF
1731
1732 int raptor_xml_writer_set_feature(raptor_xml_writer* xml_writer, rap‐
1733 tor_feature feature, int value)
1734 Set an XML writer feature feature to a particular value.
1735 Returns non 0 on failure or if the feature is unknown. The cur‐
1736 rent defined writer features are:
1737 Feature Values
1738 RAPTOR_FEATURE_WRITER_AUTO_INDENT Boolean (non 0 true)
1739 RAPTOR_FEATURE_WRITER_AUTO_EMPTY Boolean (non 0 true)
1740 RAPTOR_FEATURE_WRITER_INDENT_WIDTH Integer
1741 RAPTOR_FEATURE_WRITER_XML_DECLARATION Boolean (non 0 true)
1742
1743 If the writer_auto_indent feature is set (default true), the XML writer
1744 will automatically indent the output.
1745
1746 If the writer_auto_empty feature is set (default true), the XML writer
1747 will automatically generate empty elements if a start/end element
1748 sequence has no content.
1749
1750 If the writer_indent_width feature is set (default 2) if the XML writer
1751 is outputing indented XML, it will use that many spaces.
1752
1753 If the writer_xml_declaration feature is set (default true) the XML
1754 declaration is written at the start of serialized XML.
1755
1756 int raptor_xml_writer_set_feature_string(raptor_xml_writer *xml_writer,
1757 raptor_feature feature, const unsigned char *value)
1758 Set an XML writer feature feature to a particular string value.
1759 Returns non 0 on failure or if the feature is unknown. The cur‐
1760 rent defined XML writer features are given in rap‐
1761 tor_xml_writer_set_feature and at present only take integer val‐
1762 ues. If an integer value feature is set with this function,
1763 value is interpreted as an integer and then that value is used.
1764
1765 int raptor_xml_writer_get_feature(raptor_xml_writer* xml_writer, rap‐
1766 tor_feature feature)
1767 Get XML writer feature integer values. The allowed feature val‐
1768 ues and types are given under raptor_xml_writer_features_enumer‐
1769 ate.
1770
1771 const unsigned char *raptor_xml_writer_get_feature_string(rap‐
1772 tor_xml_writer* xml_writer, raptor_feature feature)
1773 Get XML writer feature string values. The allowed feature values
1774 and types are given under raptor_xml_writer_features_enumerate.
1775
1776 int raptor_xml_writer_get_depth(raptor_xml_writer* xml_writer)
1777 Get the current XML writer element stack depth.
1778
1779 void raptor_xml_writer_flush(raptor_xml_writer* xml_writer)
1780 Flush the XML writer output for any pending writes.
1781
1782 void raptor_xml_writer_newline(raptor_xml_writer* xml_writer)
1783 Write a newline to the XML writer (which may trigger indenting
1784 before the next item).
1785
1787 1.4.18
1788 Added atom serializer
1789
1790 Added rdfa parser
1791
1792 Added serializer features RAPTOR_FEATURE_RSS_TRIPLES and RAPTOR_FEA‐
1793 TURE_ATOM_ENTRY_URI
1794
1795 Added raptor_qname_to_counted_name
1796
1797 Added raptor_serialize_start_to_iostream
1798
1799 Added raptor_sequence_delete_at
1800
1801 Added raptor_xml_writer_newline
1802
1803 Added raptor_xml_writer_flush
1804
1805 Added raptor_xml_writer_get_depth
1806
1807 1.4.17
1808 Added SAX2 class raptor_sax2. Added new SAX2 API typedefs: rap‐
1809 tor_sax2_start_element_handler, raptor_sax2_end_element_handler, rap‐
1810 tor_sax2_characters_handler, raptor_sax2_cdata_handler, rap‐
1811 tor_sax2_comment_handler, raptor_sax2_unparsed_entity_decl_handler and
1812 raptor_sax2_external_entity_ref_handler. Added new SAX2 API functions:
1813 raptor_new_sax2(), raptor_free_sax2(), raptor_sax2_set_start_ele‐
1814 ment_handler(), raptor_sax2_set_end_element_handler(), rap‐
1815 tor_sax2_set_characters_handler(), raptor_sax2_set_cdata_handler(),
1816 raptor_sax2_set_comment_handler(), rap‐
1817 tor_sax2_set_unparsed_entity_decl_handler(), raptor_sax2_set_exter‐
1818 nal_entity_ref_handler(), raptor_sax2_set_namespace_handler(), rap‐
1819 tor_sax2_parse_start(), raptor_sax2_parse_chunk(), rap‐
1820 tor_sax2_inscope_xml_language() and raptor_sax2_inscope_base_uri()
1821
1822 Added features RAPTOR_FEATURE_WRITE_BASE_URI, RAPTOR_FEA‐
1823 TURE_WWW_HTTP_CACHE_CONTROL, RAPTOR_FEATURE_WWW_HTTP_USER_AGENT, RAP‐
1824 TOR_FEATURE_JSON_CALLBACK and RAPTOR_FEATURE_JSON_EXTRA_DATA
1825
1826 Added raptor_handler_closure structure for error handlers.
1827
1828 Added raptor_statement_compare()
1829
1830 Added raptor_iostream_write_string_python() and deprecated rap‐
1831 tor_iostream_write_string_turtle()
1832
1833 raptor_uri_set_handler(), raptor_uri_get_handler(), raptor_new_names‐
1834 paces(), raptor_namespaces_init() and raptor_new_xml_writer() now take
1835 const handler pointers.
1836
1837 Added raptor_www_set_http_cache_control()
1838
1839 Added QName class methods: raptor_qname_get_local_name(), rap‐
1840 tor_qname_get_value() and raptor_qname_get_counted_value()
1841
1842 Added raptor_iostream read handler typedefs rap‐
1843 tor_iostream_read_bytes_func, raptor_iostream_read_eof_func and added
1844 new structure raptor_iostream_handler2 replacing deprecated rap‐
1845 tor_iostream_handler.
1846
1847 Added raptor_new_iostream_from_handler2() replacing deprecated rap‐
1848 tor_new_iostream_from_handler()
1849
1850 Added raptor_new_iostream_from_sink(), raptor_new_iostream_from_file‐
1851 name(), raptor_new_iostream_from_file_handle() and rap‐
1852 tor_new_iostream_from_string().
1853
1854 Added raptor_iostream_tell deprecating raptor_iostream_get_bytes_writ‐
1855 ten_count().
1856
1857 Added raptor_iostream_read_bytes() and raptor_iostream_read_eof().
1858
1859 Added raptor_xml_element_get_language().
1860
1861 Added new enum raptor_log_level.
1862
1863 Added new typedef raptor_error_handlers. and new function rap‐
1864 tor_error_handlers_init().
1865
1866 1.4.16
1867 raptor_namespaces_init now returns an integer status
1868
1869 Added raptor_new_xml_element_from_namespace_local_name
1870
1871 Added raptor_uri_compare.
1872
1873 Added new features for the 'grddl' parser: RAPTOR_FEA‐
1874 TURE_HTML_TAG_SOUP, RAPTOR_FEATURE_MICROFORMATS and RAPTOR_FEA‐
1875 TURE_HTML_LINK.
1876
1877 Added parser feature RAPTOR_FEATURE_WWW_TIMEOUT
1878
1879 Added raptor_graph_handler typedef and raptor_set_graph_handler
1880
1881 Added raptor_www_final_uri_handler typedef and rap‐
1882 tor_www_set_final_uri_handler
1883
1884 Added raptor_www_set_connection_timeout
1885
1886 Added raptor_www_get_final_uri
1887
1888 1.4.15
1889 No changes.
1890
1891 1.4.14
1892 Add two new exported strings raptor_license_string and rap‐
1893 tor_home_url_string.
1894
1895 Added new features for the 'dot' serializer: RAPTOR_FEA‐
1896 TURE_RESOURCE_BORDER, RAPTOR_FEATURE_LITERAL_BORDER, RAPTOR_FEA‐
1897 TURE_BNODE_BORDER, RAPTOR_FEATURE_RESOURCE_FILL, RAPTOR_FEATURE_LIT‐
1898 ERAL_FILL and RAPTOR_FEATURE_BNODE_FILL
1899
1900 Added raptor_parser_generate_id
1901
1902 Added raptor_iostream_write_string_turtle
1903
1904 1.4.13
1905 No API changes.
1906
1907 1.4.12
1908 No API changes.
1909
1910 1.4.11
1911 Added raptor_get_feature_count
1912
1913 Added raptor_get_need_base_uri
1914
1915 Added parser feature RAPTOR_FEATURE_NO_NET
1916
1917 Added raptor_www_set_uri_filter, raptor_parser_set_uri_filter with fil‐
1918 ter type raptor_uri_filter_func
1919
1920 1.4.10
1921 No API changes.
1922
1923 1.4.9
1924 Added raptor_parser_get_accept_header
1925
1926 Added raptor_xml_element_is_empty
1927
1928 Added raptor_qname_get_namespace
1929
1930 Added raptor_iostream_write_uri
1931
1932 Added raptor_namespaces_qname_from_uri.
1933
1934 Added raptor_namespace_get_counted_prefix
1935
1936 Added raptor_serialize_set_namespace_from_namespace
1937
1938 Deprecated raptor_uri_is_file_uri for new rap‐
1939 tor_uri_string_is_file_uri.
1940
1941 Added raptor_xml_element_get_attributes and raptor_xml_ele‐
1942 ment_get_attributes_count
1943
1944 1.4.8
1945 Added raptor_set_namespace_handler.
1946
1947 Added XML 1.1 serializing support, feature RAPTOR_FEA‐
1948 TURE_WRITER_XML_VERSION with shortname xmlVersion for serializer and
1949 xml writer classes to support it. Added XML writer feature RAPTOR_FEA‐
1950 TURE_WRITER_XML_DECLARATION to control generation of the XML declara‐
1951 tion. Added new functions raptor_xml_any_escape_string and rap‐
1952 tor_iostream_write_xml_any_escaped_string to allow generating XML 1.1
1953 or XML 1.0.
1954
1955 RAPTOR_IDENTIFIER_TYPE_PREDICATE will no longer be generated from ver‐
1956 sion 1.4.9 onwards as the type of returned statement predicates. RAP‐
1957 TOR_IDENTIFIER_TYPE_RESOURCE will be returned.
1958
1959 RAPTOR_IDENTIFIER_TYPE_ORDINAL may no longer be generated from version
1960 1.4.9 onwards, RAPTOR_IDENTIFIER_TYPE_RESOURCE may replace it.
1961
1962 1.4.7
1963 No changes.
1964
1965 1.4.6
1966 No changes.
1967
1968 1.4.5
1969 Deprecated raptor_ntriples_string_as_utf8_string (never documented
1970 above) since it can only work with a raptor_parser object which makes
1971 it rather unusable alone.
1972
1973 Added XML writer features and support functions raptor_xml_writer_fea‐
1974 tures_enumerate, raptor_xml_writer_set_feature, rap‐
1975 tor_xml_writer_set_feature_string, raptor_xml_writer_get_feature and
1976 raptor_xml_writer_get_feature_string
1977
1978 1.4.3
1979 Added XML Writer class (raptor_xml_writer) and XML Element class (rap‐
1980 tor_xml_element)
1981
1982 Added raptor_parser_get_feature_string, raptor_parser_set_fea‐
1983 ture_string, raptor_serializer_set_feature_string, raptor_serial‐
1984 izer_get_feature_string and raptor_feature_value_type.
1985
1986 Added raptor_serializer_set_namespace, raptor_serializer_set_feature
1987 and raptor_serializer_get_feature.
1988
1989 Added raptor_new_namespace_from_uri, raptor_new_names‐
1990 pace_parts_from_string, Added raptor_namespaces_find_namespace_by_uri.
1991 and raptor_iostream_write_namespace to write a namespace declaration to
1992 an iostream.
1993
1994 Added copy constructor raptor_qname_copy and rap‐
1995 tor_iostream_write_qname to write a qname to an iostream.
1996
1997 Added raptor_sequence_join to join two sequences, leaving one empty.
1998
1999 Added raptor_iostream_write_stringbuffer to write a stringbuffer to an
2000 iostream.
2001
2002 Added N-Triples raptor_iostream_write_string_ntriples and rap‐
2003 tor_iostream_write_statement_ntriples utility functions for writing to
2004 raptor_iostreams.
2005
2006 Added raptor_uri_to_relative_counted_uri_string, raptor_uri_to_rela‐
2007 tive_uri_string. raptor_uri_print, raptor_uri_to_counted_string and
2008 raptor_uri_to_string
2009
2010 Added unicode name checking utility functions for XML 1.0 and XML 1.1
2011 name starting character and continued name character. raptor_uni‐
2012 code_is_xml10_namestartchar raptor_unicode_is_xml10_namechar, rap‐
2013 tor_unicode_is_xml11_namechar and raptor_unicode_is_xml11_names‐
2014 tartchar.
2015
2016 Added raptor_xml_name_check to check if a name is a legal XML 1.0 or
2017 1.0 name. and raptor_iostream_write_xml_escaped_string to write an
2018 XML-escaped string to an iostream.
2019
2020 Added UTF8-checking utility function raptor_utf8_check.
2021
2022 1.4.2
2023 No changes.
2024
2025 1.4.1
2026 The raptor_xml_escape_string now returns <0 on failure rather than 0,
2027 so that if an empty string is escaped, 0 bytes required is returned.
2028
2029 1.4.0
2030 Added new raptor_serializer class supporting RDF/XML (name rdfxml) and
2031 N-Triples (name ntriples).
2032 Added new raptor_iostream class
2033 Added raptor_stringbuffer_copy_to_string to allow efficient copy-out of
2034 a constructed string.
2035 Added raptor_www_fetch_to_string to allow retrieving of web content as
2036 a single string.
2037
2038 1.3.3
2039 Added raptor_calloc_memory to provide a calloc inside raptor.
2040 Added feature check_rdf_id (see raptor_set_feature documentation).
2041
2042 1.3.2
2043 Added raptor_alloc_memory to allocate memory inside raptor.
2044
2045 Added accessor functions for the public raptor_locator structure:
2046
2047 raptor_locator_line
2048 raptor_locator_column
2049 raptor_locator_byte
2050 raptor_locator_file
2051 raptor_locator_uri
2052
2053 1.3.1
2054 Correct raptor_print_statement declaration argument statement to have
2055 one less 'const', to match the code.
2056
2057 1.3.0
2058 Added the following parser methods, utility methods and helper func‐
2059 tions:
2060
2061 raptor_new_parser_for_content (Parser class constructor)
2062 raptor_get_mime_type
2063 raptor_get_feature
2064 raptor_syntax_name_check
2065 raptor_guess_parser_name
2066 raptor_features_enumerate
2067 raptor_feature_from_uri
2068 raptor_www_set_http_accept (WWW class)
2069
2070 Changed raptor_set_feature to now return an int success or failure.
2071
2072 Added the following functions:
2073 raptor_free_memory
2074 raptor_unicode_char_to_utf8
2075 raptor_utf8_to_unicode_char
2076 raptor_vsnprintf
2077
2078 Added the raptor_sequence class, its constructor, destructor, methods
2079 and helper functions.
2080
2081 Added the raptor_stringbuffer class and constructor, destructor and
2082 methods.
2083
2084 Deprecated raptor_print_statement_detailed always intended to be inter‐
2085 nal.
2086
2087 1.2.0
2088 Added raptor_syntaxes_enumerate to get full information on syntax mime
2089 type and URIs as well as name and label.
2090
2091 N-Triples Plus parser renamed to Turtle (name turtle)
2092
2093 1.1.0
2094 Added N-Triples Plus parser (name ntriples-plus)
2095
2096 Made URI class constructors, methods and factory methods as well as
2097 some other utility functions using or returning URIs or literals take
2098 unsigned char* rather than char*. The affected calls are:
2099
2100 URI factory methods changed to all take/return unsigned char* for URI
2101 strings:
2102 raptor_new_uri_func
2103 raptor_new_uri_from_local_name_func
2104 raptor_new_uri_relative_to_base_func
2105 raptor_uri_as_string_func
2106 raptor_uri_as_counted_string_func
2107
2108 Constructors and methods changed to take/return unsigned char* for URI
2109 strings:
2110 raptor_statement_part_as_counted_string
2111 raptor_statement_part_as_string
2112 raptor_new_uri
2113 raptor_new_uri_from_uri_local_name
2114 raptor_new_uri_relative_to_base
2115 raptor_uri_as_string
2116 raptor_uri_as_counted_string
2117 raptor_print_ntriples_string
2118
2119 Changed to use unsigned char* for URI strings, char* for filenames:
2120 raptor_uri_resolve_uri_reference
2121 raptor_uri_filename_to_uri_string
2122 raptor_uri_uri_string_to_filename
2123 raptor_uri_uri_string_to_filename_fragment
2124 raptor_uri_is_file_uri
2125
2126 Changed to return unsigned char* for UTF8 string:
2127 raptor_ntriples_string_as_utf8_string
2128
2129 Added raptor_parsers_enumerate to discover supported parsers.
2130
2131 Added raptor_uri_uri_string_to_filename_fragment with fragment arg to
2132 return the URI fragment.
2133
2134 Made the raptor_namespace, raptor_namespace_stack and raptor_qname
2135 class and APIs public.
2136
2137 Added feature non_nfc_fatal (see raptor_set_feature documentation).
2138
2139 1.0.0
2140 Removed the following deprecated methods and functions (see 0.9.6
2141 changes for the new names):
2142 raptor_free, raptor_new, raptor_ntriples_free, raptor_ntriples_new,
2143 raptor_ntriples_parse_file, raptor_ntriples_set_error_handler, rap‐
2144 tor_ntriples_set_fatal_error_handler, raptor_ntriples_set_state‐
2145 ment_handler and raptor_parser_abort.
2146
2147 Added raptor_parse_file_stream for reading FILE* streams without neces‐
2148 sarily having a file.
2149
2150 0.9.12
2151 Added raptor_new_uri_for_retrieval to turn URI references into URIs
2152 suitable for retrieval (no fragments).
2153
2154 0.9.11
2155 Added raptor_get_name and raptor_get_label.
2156
2157 raptor_xml_escape_string now takes error message handler, data pointer,
2158 loses parser argument.
2159
2160 Added raptor_set_default_generate_id_parameters and raptor_set_gener‐
2161 ate_id_handler to control the default generation of IDs, allow full
2162 customisation.
2163
2164 0.9.10
2165 Added raptor_set_parser_strict and raptor_www_no_www_library_init_fin‐
2166 ish.
2167
2168 raptor_xml_escape_string now takes an output string length pointer.
2169
2170 Added raptor_statement_part_as_counted_string, raptor_state‐
2171 ment_part_as_string and raptor_parse_abort.
2172
2173 Deprecated raptor_parser_abort.
2174
2175 0.9.9
2176 Added raptor_www class and all its constructors, destructor, methods,
2177 calls.
2178
2179 Added raptor_parse_uri, raptor_parser_abort, rap‐
2180 tor_ntriples_term_as_string and raptor_xml_escape_string.
2181
2182 0.9.7
2183 raptor_parse_chunk, raptor_new_uri_from_id, arguments are now unsigned
2184 char.
2185
2186 Added raptor_new_uri_for_xmlbase.
2187
2188 0.9.6
2189 In this version, the raptor/ntriples parser calling APIs were modified.
2190 The following table lists the changes:
2191
2192 OLD API NEW API (0.9.6+)
2193 raptor_new() raptor_new_parser("rdfxml")
2194 ntriples_new() raptor_new_parser("ntriples")
2195 raptor_free raptor_free_parser
2196 ntriples_free raptor_ntriples_parser
2197 raptor_ntriples_parse_file raptor_parse_file
2198 raptor_ntriples_set_error_handler raptor_set_error_handler
2199 raptor_ntriples_set_fatal_error_handler raptor_set_fatal_error_handler
2200 raptor_ntriples_set_statement_handler raptor_set_statement_handler
2201
2203 RDF/XML Syntax (Revised), Dave Beckett (ed.) W3C Recommendation,
2204 http://www.w3.org/TR/rdf-syntax-grammar/ ⟨http://www.w3.org/TR/rdf-
2205 syntax-grammar/⟩
2206
2207 N-Triples, in RDF Test Cases, Jan Grant and Dave Beckett (eds.) W3C
2208 Recommendation, http://www.w3.org/TR/rdf-testcases/#ntriples
2209 ⟨http://www.w3.org/TR/rdf-testcases/#ntriples⟩
2210
2211 Turtle - Terse RDF Triple Language, Dave Beckett,
2212 http://www.dajobe.org/2004/01/turtle/
2213 ⟨http://www.dajobe.org/2004/01/turtle/⟩
2214
2215 RSS 0.91 spec revision 3, Dan Libby, Netscape,
2216 http://my.netscape.com/publish/formats/rss-spec-0.91.html
2217 ⟨http://my.netscape.com/publish/formats/rss-spec-0.91.html⟩
2218
2219 RDF Site Summary (RSS) 1.0, http://purl.org/rss/1.0/spec
2220 ⟨http://purl.org/rss/1.0/spec⟩
2221
2222 Atom 1.0 syndication format, RFC 4287,
2223 http://www.ietf.org/rfc/rfc4287.txt
2224 ⟨http://www.ietf.org/rfc/rfc4287.txt⟩
2225
2226 Gleaning Resource Descriptions from Dialects of Languages (GRDDL), Dan
2227 Connolly (ed.), W3C Recommendation, 2007-09-11,
2228 http://www.w3.org/TR/2007/REC-grddl-20070911/
2229 ⟨http://www.w3.org/TR/2007/REC-grddl-20070911/⟩
2230
2231
2233 rapper(1),[22mraptor-config(1)
2234
2236 Dave Beckett - http://purl.org/net/dajobe/
2237 ⟨http://purl.org/net/dajobe/⟩
2238
2239
2240
2241 2008-06-19 libraptor(3)