---
name: "libraptor"
section: "3"
platform: "linux"
package: "libraptor1-dev"
version: "1.4.21-11+b1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/libraptor"
---

# libraptor(3)

Raptor RDF parser and serializer library

## NAME

libraptor - Raptor RDF parser and serializer library

## SYNOPSIS

```
#include <raptor.h>
raptor_init();
raptor_parser *p=raptor_new_parser("rdfxml");
raptor_set_statement_handler(p,NULL,print_triples);
raptor_uri *file_uri=raptor_new_uri("http://example.org/");
raptor_parse_file(p,file_uri,base_uri);
raptor_parse_uri(p,uri,NULL);
raptor_free_parser(p);
raptor_free_uri(file_uri);
raptor_finish();
cc file.c -lraptor
```

## DESCRIPTION

The *Raptor* library provides a high-level interface to a set of parsers and serializers that generate Resource Description Framework (RDF) triples by parsing syntaxes or serialize the triples into syntaxes.

The supported parsing syntaxes include RDF/XML, N-Triples, Turtle, TRiG, RSS tag soup (including all RSS and Atoms), GRDDL, RDFa and the serializing syntaxes include RDF/XML (3 varieties), N-Triples, Turtle, RSS 1.0, Atom 1.0, GraphViz DOT and RDF/JSON. The RDF/XML parser can use either *expat* or *libxml* XML parsers for providing the SAX event stream. The library functions are arranged in an object-oriented style with constructors, destructors and method calls.  The statements and error messages are delivered via callback functions.

Raptor contains a URI-reference parsing and resolving (not retrieval) class (raptor\_uri) sufficient for dealing with URI-references inside RDF.  This functionality is modular and can be transparently replaced  with another existing and compatible URI implementation.

It also provides a URI-retrieval class (raptor\_www) for wrapping existing library such as libcurl, libxml2 or BSD libfetch that provides full or partial retrieval of data from URIs and an I/O stream abstraction (raptor\_iostream) for supportin serializing to a variety of outputs.

Raptor uses Unicode strings for RDF literals and URIs and preserves them throughout the library.  It uses the UTF-8 encoding of Unicode at the API for passing in or returning Unicode strings.  It is intended that the preservation of Unicode for URIs will support Internationalized Resource Identifiers (IRIs) which are still under development and standardisation.

## LIBRARY INITIALISATION AND CLEANUP

- **raptor\_init()**

  - **raptor\_finish()**

  Initialise and cleanup the library.  These must be called before any raptor class such as raptor\_parser, raptor\_uri is created or used. Note: as of 1.4.19 these are wrappers around a static instance of the new **raptor\_world** class.  In Raptor 2.0 this initialisation and cleanup method will be removed.

- **void raptor\_set\_libxslt\_security\_preferences(void \****security\_preferences***)**

  Set libxslt security preferences object.

- **void raptor\_set\_libxml\_flags(int** *flags***)**

  Set libxml flags from the choices: **RAPTOR\_LIBXML\_FLAGS\_GENERIC\_ERROR\_SAVE**: save/restore the libxml generic error handler when parsing and **RAPTOR\_LIBXML\_FLAGS\_STRUCTURED\_ERROR\_SAVE: save/restore** **the libxml structured error handler when parsing.**

## PARSER CLASS

**This class provides the functionality of turning syntaxes into** **RDF triples - RDF parsing.**

## PARSER CONSTRUCTORS

- **raptor\_parser\* raptor\_new\_parser(name)**

  **Create a new raptor parser object for the parser with name** *name* **currently either "rdfxml", "turtle" or** **"rss-tag-soup" for the RSS Tag Soup parser.**

- **raptor\_parser\* raptor\_new\_parser\_for\_content(raptor\_uri \****uri***, const char \****mime\_type***, const unsigned char \****buffer***, size\_t** *len***, const unsigned char \****identifier***)**

  **Create a new raptor parser object for a syntax identified by URI** *uri*, MIME type *mime\_type*, some initial content *buffer* of size *len* or content with identifier *identifier*.  See the raptor\_guess\_parser\_name description for further details.

## PARSER DESTRUCTOR

- **void raptor\_free\_parser(raptor\_parser \****parser***)**

  Destroy a Raptor parser object.

## PARSER MESSAGE CALLBACK METHODS

Several methods can be registered for the parser that return a variable-argument message in the style of [printf(3)](/printf/3.md).  These also return a *raptor\_locator* that can contain URI, file, line, column and byte counts of where the message is about. This structure can be used with the raptor\_format\_locator, raptor\_print\_locator functions below or the structures fields directly, which are defined in raptor.h

- **void raptor\_set\_fatal\_error\_handler(raptor\_parser\*** *parser, void \*user\_data, raptor\_message\_handler handler)*

  Set the parser fatal error handler callback.

- **void raptor\_set\_error\_handler(raptor\_parser\*** *parser***, void \****user\_data***, raptor\_message\_handler** *handler***)**

  Set the parser non-fatal error handler callback.

- **void raptor\_set\_warning\_handler(raptor\_parser\*** *parser***, void \****user\_data***, raptor\_message\_handler** *handler***)**

  Set the parser warning message handler callback.

- **raptor\_set\_namespace\_handler(raptor\_parser\*** *parser***, void\*** *user\_data***, raptor\_namespace\_handler** *handler***)**

  Set the namespace declaration handler callback.

## PARSER STATEMENT CALLBACK METHOD

The parser allows the registration of a callback function to return the statements to the application.

- **void raptor\_set\_statement\_handler(raptor\_parser\*** *parser***, void \****user\_data***, raptor\_statement\_handler** *handler***)**

  Set the statement callback function for the parser. The *raptor\_statement* structure is defined in raptor.h and includes fields for the subject, predicate, object of the statements along with their types and for literals, language and datatype.

## PARSER PARSING METHODS

These methods perform the entire parsing in one method. Statements warnings, errors and fatal errors are delivered via the registered statement, error etc. handler functions.

In both of these methods, the base URI is required for the RDF/XML parser (name "rdfxml") and Turtle parser (name "turtle"). The N-Triples parser (name "ntriples") or RSS Tag Soup parser (name "rss-tag-soup") do not use this.

- **int raptor\_parse\_file(raptor\_parser\*** *parser***, raptor\_uri \****uri***, raptor\_uri \****base\_uri***)**

  Parse the given filename (a URI like file:filename) according to the optional base URI *base\_uri*.  If *uri* is NULL, read from standard input and *base\_uri* is then required.

- **int raptor\_parse\_file\_stream(raptor\_parser\*** *parser***, FILE\*** *stream***, const char\*** *filename***, raptor\_uri \****base\_uri***)**

  Parse the given C FILE\* stream according to the base URI *base\_uri* (required).  *filename* is optional and if given, is used for error messages via the raptor\_locator structure.

- **int raptor\_parse\_uri(raptor\_parser\*** *parser***, raptor\_uri\*** *uri***, raptor\_uri \****base\_uri***)**

  Parse the URI according to the base URI *base\_uri*, or NULL if not needed.  If no base URI is given, the *uri* is used. This method depends on the raptor\_www subsystem (see **WWW Class** section below) and an existing underlying URI retrieval implementation such as libcurl, libxml or BSD libfetch to retrieve the content.

## PARSER CHUNKED PARSING METHODS

These methods perform the parsing in parts by working on multiple chunks of memory passed by the application. Statements warnings, errors and fatal errors are delivered via the registered statement, error etc. handler functions.

- **int raptor\_start\_parse(raptor\_parser\*** *parser***, const char \****uri***)**

  Start a parse of chunked content with the base URI *uri* or NULL if not needed. The base URI is required for the RDF/XML parser (name "rdfxml") and Turtle parser (name "turtle"). The N-Triples parser (name "ntriples") or RSS Tag Soup parser (name "rss-tag-soup") do not use this.

- **int raptor\_parse\_chunk(raptor\_parser\*** *parser***, const unsigned char \*buffer, size\_t** *len***, int** *is\_end***)**

  Parse the memory at *buffer* of size *len* returning statements via the statement handler callback. If *is\_end* is non-zero, it indicates the end of the parsing stream. This method can only be called after **raptor\_start\_parse()**.

## PARSER UTILITY METHODS

- **const char\* raptor\_get\_mime\_type(raptor\_parser\*** *rdf\_parser***)**

  Return the MIME type for the parser.

- **void raptor\_set\_parser\_strict(raptor\_parser \****parser***, int** *is\_strict***)**

  Set the parser to strict (*is\_strict* not zero) or lax (default) mode.  The detail of the strictness can be controlled by raptor\_set\_feature.

- **int raptor\_set\_feature(raptor\_parser \****parser***, raptor\_feature** *feature***, int** *value***)**

  Set a parser feature *feature* to a particular *value*. Returns non 0 on failure or if the feature is unknown. The current defined parser features are:\
     *Feature                                 Values*\
     **RAPTOR\_FEATURE\_ALLOW\_BAGID**              Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_ALLOW\_NON\_NS\_ATTRIBUTES**  Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_ALLOW\_OTHER\_PARSETYPES**   Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_ALLOW\_RDF\_TYPE\_RDF\_LIST**  Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_ASSUME\_IS\_RDF**            Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_CHECK\_RDF\_ID**             Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_HTML\_LINK**                Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_HTML\_TAG\_SOUP**            Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_MICROFORMATS**             Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_NON\_NFC\_FATAL**            Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_NORMALIZE\_LANGUAGE**       Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_NO\_NET**                   Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_RELATIVE\_URIS**            Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_SCANNING**                 Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_WARN\_OTHER\_PARSETYPES**    Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_WWW\_TIMEOUT**              Integer\
     **RAPTOR\_FEATURE\_WWW\_HTTP\_CACHE\_CONTROL**   String\
     **RAPTOR\_FEATURE\_WWW\_HTTP\_USER\_AGENT**      String

If the *allow\_bagid* feature is true (default true) then the RDF/XML parser will support the rdf:bagID attribute that was removed from the RDF/XML language when it was revised.  This support may be removed in future.

If the *allow\_non\_ns\_attributes* feature is true (default true), then the RDF/XML parser will allow non-XML namespaced attributes to be accepted as well as rdf: namespaced ones.  For example, 'about' and 'ID' will be interpreted as if they were rdf:about and rdf:ID respectively.

If the *allow\_other\_parsetypes* feature is true (default true) then the RDF/XML parser will allow unknown parsetypes to be present and will pass them on to the user. Unimplemented at present.

If the *allow\_rdf\_type\_rdf\_list* feature is true (default false) then the RDF/XML parser will generate the idList rdf:type rdf:List triple in the handling of rdf:parseType="Collection".  This triple was removed during the revising of RDF/XML after collections were initially added.

If the *assume\_is\_rdf* feature is true (default false), then the RDF/XML parser will assume the content is RDF/XML, not require that rdf:RDF root element, and immediately interpret the content as RDF/XML.

If the *check\_rdf\_id* feature is true (default true) then rdf:ID values will be checked for duplicates and cause an error if found.

if the *html\_link* feature is true (default true), look for head &lt;link&gt; to type rdf/xml for GRDDL parser

If the *html\_tag\_soup* feature is true (default true), use a lax HTML parser if an XML parser fails when read HTML for GRDDL parser.

If the *microformats* feature is true (default true), look for microformats for GRDDL parser.

If the *non\_nfc\_fatal* feature is true (default false) then illegal Unicode Normal Form C in literals will give a fatal error, otherwise it gives a warning.

If the *normalize\_language* feature is true (default true) then XML language values such as from xml:lang will be normalized to lowercase.

If the *no\_net* feature is true (default false) then network requests are denied.

If the *scanning* feature is true (default false), then the RDF/XML parser will look for embedded rdf:RDF elements inside the XML content, and not require that the XML start with an rdf:RDF root element.

If the *www\_timeout* feature is set to an integer larger than 0, it sets the timeout in seconds for internal WWW URI requests for the GRDDL parser.

If the *www\_http\_cache\_control* feature is set to a string value (default none), it is sent as the value of the HTTP Cache-Control: header in requests.

If the *www\_http\_user\_agent* feature is set to a string value, it is sent as the value of the HTTP User-Agent: header in requests.

- **raptor\_parser\_set\_feature\_string(raptor\_parser \****parser***, raptor\_feature** *feature***, const unsigned char \****value***)**

  Set a parser feature *feature* to a particular string *value*. Returns non 0 on failure or if the feature is unknown. The current defined parser features are given in **raptor\_set\_feature** and at present only take integer values. If an integer value feature is set with this function, *value* is interpreted as an integer and then that value is used.

- **int raptor\_get\_feature(raptor\_parser\*** *parser***, raptor\_feature** *feature***)**

  Get parser feature integer values.  The allowed *feature* values and types are given under **raptor\_features\_enumerate**.

- **const unsigned char\* raptor\_parser\_get\_feature\_string(raptor\_parser \****parser***, raptor\_feature** *feature***)**

  Get parser feature string values. The allowed *feature* values and types are given under **raptor\_features\_enumerate**.

- **unsigned int raptor\_get\_feature\_count(void)**

  Get the count of features defined. Prefered to the compile time-only symbol **RAPTOR\_FEATURE\_LAST** which returns the maximum value, not the count. Added raptor\_get\_need\_base\_uri

- **int raptor\_feature\_value\_type(const raptor\_feature feature)**

  Get a raptor feature value tyype - integer or string.

- **raptor\_locator\* raptor\_get\_locator(raptor\_parser\*** *rdf\_parser***)**

  Return the current raptor\_locator object for the parser. This is a public structure defined in raptor.h that can be used directly, or formatted via raptor\_print\_locator.

- **void raptor\_get\_name(raptor\_parser \****parser***)**

  Return the string short name for the parser.

- **void raptor\_get\_label(raptor\_parser \****parser***)**

  Return a string label for the parser.

- **void raptor\_set\_default\_generate\_id\_parameters(raptor\_parser\*** *rdf\_parser***, char \****prefix***, int** *base***)**

  Control the default method for generation of IDs for blank nodes and bags.  The method uses a short string *prefix* and an integer *base* to generate the identifier which is not guaranteed to be a strict concatenation.  If *prefix* is NULL, the default is used.  If base is less than 1, it is initialised to 1.

- **void raptor\_set\_generate\_id\_handler(raptor\_parser\*** *parser***, void \****user\_data***, raptor\_generate\_id\_handler** *handler***)**

  Allow full customisation of the generated IDs by setting a callback *handler* and associated *user\_data* that is called whenever a blank node or bag identifier is required.  The memory returned is deallocated inside raptor.  Some systems require this to be allocated inside the same library, in which case the  **raptor\_alloc\_memory** function may be useful.

- **void raptor\_parser\_set\_uri\_filter(raptor\_parser\*** *parser***, raptor\_uri\_filter\_func** *filter***, void\*** *user\_data***)**

  Set the URI filter function *filter* for URIs retrieved during parsing by the the raptor\_parser.

- **int raptor\_get\_need\_base\_uri(raptor\_parser\*** *rdf\_parser***)**

  Get a boolean whether this parser needs a base URI to start parsing.

- **unsigned char\* raptor\_parser\_generate\_id(raptor\_parser\*** *rdf\_parser***, raptor\_genid\_type** *type***)**

  Generate an ID for a parser of type *type*, either **RAPTOR\_GENID\_TYPE\_BNODEID** or **RAPTOR\_GENID\_TYPE\_BAGID**. This uses any configuration set by **raptor\_set\_generate\_id\_handler**.

- **void raptor\_set\_graph\_handler(raptor\_parser\*** *parser***, void\*** *user\_data***, raptor\_graph\_handler** *handler***)**

  Set the graph handler callback.

- **raptor\_world\* raptor\_parser\_get\_world(raptor\_parser\*** *rdf\_parser***)**

  Get the world object for the given *rdf\_parser*.

## PARSER UTILITY FUNCTIONS

- **int raptor\_parsers\_enumerate(const unsigned int** *counter***, const char \*\****name***, const char \*\****label***)**

  Return the parser name/label for a parser with a given integer counter, returning non-zero if no such parser at that offset exists.  The counter should start from 0 and be incremented by 1 until the function returns non-zero.

- **int raptor\_syntaxes\_enumerate(const unsigned int** *counter***, const char \*\*name, const char \*\****label***, const char \*\****mime\_type***, const unsigned char \*\****uri-string***)**

  Return the name, label, mime type or URI string (all optional) for a parser syntax with a given integer counter, returning non-zero if no such syntax parser at that offset exists. The counter should start from 0 and be incremented by 1 until the function returns non-zero.

- **int raptor\_features\_enumerate(const raptor\_feature** *feature***, const char \*\****name***, raptor\_uri \*\****uri***, const char \*\****label***)**

  Return the name, URI, string label (all optional) for a parser *feature*, returning non-zero if no such feature exists.

Raptor features have URIs that are constructed from the URI *http://feature.librdf.org/raptor-* and the *name* so for example feature *scanForRDF* has URI *http://feature.librdf.org/raptor-scanForRDF*

- **int raptor\_syntax\_name\_check(const char \****name***)**

  Check *name* is a known syntax name.

- **const char\* raptor\_guess\_parser\_name(raptor\_uri \****uri***, const char \****mime\_type***, const unsigned char \****buffer***, size\_t** *len***, const unsigned char \****identifier***)**

  Guess a parser name for a syntax identified by URI *uri*, MIME type *mime\_type*, some initial content *buffer* of size *len* or with content identifier *identifier*.  All of these parameters are optional and only used if not NULL.  The parser is chosen by scoring the hints that are given.

- **raptor\_feature raptor\_feature\_from\_uri(raptor\_uri \****uri***)**

  Turn a URI *uri* into a raptor feature identifier, or \<0 if the feature is unknown.  The URIs are described below raptor\_set\_feature.

## STATEMENT UTILITY FUNCTIONS

- **int raptor\_statement\_compare(const raptor\_statement \****s1***, const raptor\_statement \****s2***)**

  Compare two statements and return an ordering between them.

- **void raptor\_print\_statement(const raptor\_statement\* const** *statement***, FILE \****stream***)**

  Print a raptor statement object in a simple format for debugging only. The format of this output is not guaranteed to remain the same between releases.

- **void raptor\_print\_statement\_as\_ntriples(const raptor\_statement\*** *statement***, FILE \****stream***)**

  Print a raptor statement object in N-Triples format, using all the escapes as defined in http://www.w3.org/TR/rdf-testcases/#ntriples ⟨http://www.w3.org/TR/rdf-testcases/#ntriples⟩

- **raptor\_statement\_part\_as\_counted\_string(const void \****term***, raptor\_identifier\_type** *type***, raptor\_uri\*** *literal\_datatype***, const unsigned char \****literal\_language***, size\_t\*** *len\_p***)**

  - **char\* raptor\_statement\_part\_as\_string(const void \****term***, raptor\_identifier\_type** *type***, raptor\_uri\*** *literal\_datatype***, const unsigned char \****literal\_language***)**

  Turns part of raptor statement into N-Triples format, using all the escapes as defined in http://www.w3.org/TR/rdf-testcases/#ntriples ⟨http://www.w3.org/TR/rdf-testcases/#ntriples⟩ The part (subject, predicate, object) of the raptor\_statement is passed in as *term*, the part type (subject\_type, predicate\_type, object\_type) is passed in as *type*.  When the part is a literal, the *literal\_datatype* and *literal\_language* fields are set, otherwise NULL (usually object\_datatype, object\_literal\_language).

-

  If **raptor\_statement\_part\_as\_counted\_string** is used, the length of the returned string is stored in \**len\_p* if not NULL.

## LOCATOR UTILITY FUNCTIONS

- **int raptor\_format\_locator(char \****buffer***, size\_t** *length***, raptor\_locator\*** *locator***)**

  This method takes a *raptor\_locator* object as passed to an error, warning or other handler callback and formats it into the *buffer* of size *length* bytes.  If *buffer* is NULL or *length* is insufficient for the size of the formatted locator, returns the number of additional bytes required in the buffer to write the locator.

  In particular, if this form is used:\
     length=raptor\_format\_locator(NULL, 0, locator) it will return in *length* the size of a buffer that can be allocated for *locator* and a second call will perform the formatting:\
     raptor\_format\_locator(buffer, length, locator)

- **void raptor\_print\_locator(FILE \****stream***, raptor\_locator\*** *locator***)**

  This method takes a *raptor\_locator* object as passed to an error, warning or other handler callback, formats and prints it to the given stdio *stream*.

- **int raptor\_locator\_line(raptor\_locator \*locator)**

  Returns the line number in a locator structure or \<0 if not available.

- **int raptor\_locator\_column(raptor\_locator \*locator)**

  Returns the column number in a locator structure or \<0 if not available.

- **int raptor\_locator\_byte(raptor\_locator \*locator)**

  Returns the byte offset in a locator structure or \<0 if not available.

- **const char \* raptor\_locator\_file(raptor\_locator \*locator)**

  Returns the filename in a locator structure or NULL if not available. Note the returned pointer is to a shared string that must be copied if needed.

- **const char \* raptor\_locator\_uri(raptor\_locator \*locator)**

  Returns the URI string in a locator structure or NULL if not available.  Note this does not return a raptor\_uri\* pointer and the returned pointer is to a shared string that must be copied if needed.

## N-TRIPLES UTILITY FUNCTIONS

- **void raptor\_print\_ntriples\_string(FILE\*** *stream***, const char\*** *string***, const char** *delim***)**

  This is a standalone function that prints the given string according to N-Triples escaping rules, expecting to be terminated by delimiter *delim* which is usually either ', " or \<.  If a null delimiter \\0 is given, no extra escaping is performed.

- **int raptor\_iostream\_write\_string\_ntriples(raptor\_iostream \****iostr***, const unsigned char \****string***, size\_t** *len***, const char** *delim***)**

  Write an N-Triples encoded version of the given string to iostream *iostr*.  If *delim* is given, that is the ending delimeter of the encoded string and it will be escaped in the output as appropriate. Useful delim values are ', " and \>.  If a null delimiter \\0 is given, no extra escaping is performed.

- int raptor\_iostream\_write\_string\_python(raptor\_iostream \**iostr*, const unsigned char \**string*, size\_t *len*, const char *delim*, int *flags*)

  Write *string* encoded to an iostream according to the delimeter *delim* and encoding flags.  The *flag* value selects formatting according to the appropriate Python-related languages such as N-Triples (0), Turtle (1), Turtle long quoted string (2), JSON (3).

- **void raptor\_iostream\_write\_statement\_ntriples(raptor\_iostream\* iostr, const raptor\_statement \*statement)**

  Write an N-Triples encoded version of the raptor\_statement *statement* to iostream *iostr*.

- **void raptor\_iostream\_write\_string\_turtle(raptor\_iostream\*** *iostr***, const unsigned char\*** *string***, size\_t** *len***)**

  DEPRECATED in 1.4.17 - use raptor\_iostream\_write\_string\_python instead. Write an UTF-8 *string* of length *len* using the Turtle "longString" triple quoting format to the iostream *iostr*.

- **const char\* raptor\_ntriples\_term\_as\_string (raptor\_ntriples\_term\_type** *term***)**

  Deprecated, for internal use.

## XML UTILITY FUNCTIONS

- **int raptor\_xml\_any\_escape\_string(const unsigned char\*** *string***, size\_t** *len***, unsigned char\*** *buffer***, size\_t** *length***, char** *quote***, int** *xml\_version***, raptor\_simple\_message\_handler** *error\_handler***, void\*** *error\_data***)**

  - **int raptor\_xml\_escape\_string(const unsigned char \****string***, size\_t** *len***, unsigned char \****buffer***, size\_t** *length***, char** *quote***, raptor\_message\_handler** *error\_handler***, void \****error\_data***)**

  Apply the XML escaping rules to the string given in (string, len) into the *buffer* of size *length*.  If *quote* is given, the escaped content is for an XML attribute and the appropriate quote character  XML element content (CDATA).   The *error\_handler* method along with *error\_data* allow error reporting to be given. If buffer is NULL, returns the size of the buffer required to escape. Otherwise the return value is the number of bytes used or \<0 on failure.

-

  When an *xml\_version* argument is present and has a value 10 (XML 1.0) or 11 (XML 1.1) then that version is used.  The default with no argument is to generate XML 1.0.

- **int raptor\_iostream\_write\_xml\_any\_escaped\_string(raptor\_iostream\*** *iostr***, const unsigned char\*** *string***, size\_t** *len***, char** *quote***, int** *xml\_version***, raptor\_simple\_message\_handler** *error\_handler***, void\*** *error\_data***)**

  - **int raptor\_iostream\_write\_xml\_escaped\_string(raptor\_iostream\*** *iostr***, const unsigned char \****string***, size\_t** *len***, char** *quote***, raptor\_simple\_message\_handler** *error\_handler***, void \****error\_data***)**

  Write an XML-escaped version of the string given in (string, len) to iostream *iostr*.  If *quote* is given, the escaped content is for an XML attribute and the appropriate quote character  is used, otherwise it is XML element content (CDATA).  The *error\_handler* method along with *error\_data* allow error reporting to be given.

-

  When an *xml\_version* argument is present and has a value 10 (XML 1.0) or 11 (XML 1.1) then that version is used.  The default with no argument is to generate XML 1.0.

- **int raptor\_xml\_name\_check(const unsigned char \****string***, size\_t** *length***, int xml\_version)**

  Check that the given *string* of *length* bytes is a legal XML name according to XML 1.0 or XML 1.1. *xml\_version* is set to 10 or 11 respectively. Returns non-zero if the name is legal.

## MEMORY UTILITY FUNCTIONS

- **void raptor\_free\_memory(void \****ptr***)**

  Free memory allocated inside raptor.  Some systems require memory allocated in a library to be deallocated inside that library. This function can be used in that situation to free memory allocated by raptor, such as the result of the *\_to\_* methods that return allocated memory such as **raptor\_uri\_to\_filename**, **raptor\_uri\_to\_string**, **raptor\_uri\_to\_relative\_counted\_uri\_string**, **raptor\_uri\_to\_relative\_uri\_string** or  **raptor\_new\_namespace\_parts\_from\_string**.

- **void\* raptor\_alloc\_memory(size\_t** *size***)**

  Allocate memory inside the raptor library.  Some systems require memory allocated in a library to be deallocated inside that library. This function can be used in that situation to allocate memory for raptor to free later, such as inside the handler function declared with **raptor\_set\_generate\_id\_handler** which returns new memory.

- **void\* raptor\_calloc\_memory(size\_t** *nmemb***, size\_t** *size***)**

  Allocate zeroed array of items inside raptor.  Some systems require memory allocated in a library to be deallocated inside that library. This function can be used in that situation to clear an array of allocated memory for raptor to use, for freeing later, such as inside the handler function declared with **raptor\_set\_generate\_id\_handler** which returns new memory.

## UNICODE UTILITY FUNCTIONS

- **int raptor\_unicode\_char\_to\_utf8(raptor\_unichar** *c***, unsigned char \****output***)**

  Turn a Unicode character into UTF8 bytes in *output* of size *c* bytes which must be of sufficient size.  Returns the number of bytes encoded or \<0 on failure.

- **int raptor\_utf8\_to\_unicode\_char(raptor\_unichar \****output***, const unsigned char \****input***, int** *length***)**

  Decode a sequence UTF8 bytes in *input* of size *length* into a Unicode character in *output* returning the number of bytes used or \<0 on failure.

- **int raptor\_utf8\_check(const unsigned char \****string***, size\_t** *len***gth)**

  Check that a given *string* is legal UTF-8 encoding and includes only legal Unicode characters U+0 to U+0x10ffff inclusive. Returns non-0 if the string is good.

- **int raptor\_unicode\_is\_xml11\_namestartchar(raptor\_unichar** *c***)**

  - **int raptor\_unicode\_is\_xml10\_namestartchar(raptor\_unichar** *c***)**

  - **int raptor\_unicode\_is\_xml11\_namechar(raptor\_unichar** *c***)**

  - **int raptor\_unicode\_is\_xml10\_namechar(raptor-unichar** *c***)**

  Check that given Unicode characters are allowed as XML 1.0 or XML 1.0 names - either as the starting character (**\*\_namestartchar**) or continuing character (**\*\_namechar**). Returns non-0 if the character is allowed.

## ERROR UTILITY FUNCTIONS

- **void raptor\_error\_handlers\_init(raptor\_error\_handlers\*** *error\_handlers***)**

  Initialise an error\_handlers structure after the log level handlers and user data pointers have been set.

## MISCELLANEOUS UTILITY FUNCTIONS

- **char\* raptor\_vsnprintf(const char \*message, va\_list arguments)**

  Compatibility wrapper around vsnprintf.

## STATIC VARIABLES

There are several read-only static variables in the raptor library:

- **const char \* const raptor\_short\_copyright\_string**

  Short copyright string, suitable for one line.

- **const char \* const raptor\_copyright\_string**

  Full copyright over several lines including URLs.

- **const char \* const raptor\_version\_string**

  The version as a string

- **const unsigned int raptor\_version\_major**

  The major version number as an integer.

- **const unsigned int raptor\_version\_minor**

  The minor version number as an integer.

- **const unsigned int raptor\_version\_release**

  The release version number as an integer.

- **const unsigned int raptor\_version\_decimal**

  The version number as a single decimal.

- **const char \* const raptor\_license\_string**

  The license string over several lines including URLs.

- **const char \* const raptor\_home\_url\_string**

  The home page URL as a string.

## SERIALIZER CLASS

This class provides the functionality of turning RDF triples into syntaxes - RDF serializing.

## SERIALIZER CONSTRUCTOR

- **raptor\_serializer\* raptor\_new\_serializer(const char \****name***)**

  Create a new raptor serializer object for the serializer with name *name* currently either "rdfxml" or "ntriples". or "rss-1.0" for the RSS 1.0 serializer.

## SERIALIZER DESTRUCTOR

- **void raptor\_free\_serializer(raptor\_serializer\*** *rdf\_serializer***)**

  Destroy a Raptor serializer object.

## SERIALIZER SERIALIZING METHODS

- **int raptor\_serialize\_start(raptor\_serializer\*** *rdf\_serializer***, raptor\_uri \****uri***, raptor\_iostream \****iostream***)**

  Start to serialize content using the given *iostream* to write to with optional base URI *uri*. The *iostream* becomes owned by the serializer object and is destroyed at the end of serializing when raptor\_serialize\_end() is called. Note that  some syntaxes may refuse to serialize without a base URI, such as RDF/XML.

- **int raptor\_serialize\_start\_to\_iostream(raptor\_serializer\*** *rdf\_serializer***, raptor\_uri\*** *uri***, raptor\_iostream\*** *iostream***)**

  Start to serialize content using the given *iostream* to write to with optional base URI *uri*.  The *iostream* does NOT become owned by the serializer object and the caller may continue to write to it after serializing is finished.  Note that some syntaxes may refuse to serialize without a base URI, such as RDF/XML.

- **int raptor\_serialize\_start\_to\_filename(raptor\_serializer\*** *rdf\_serializer***, const char \****filename***)**

  Start to serialize content to the file *filename* which is opened for writing. The base URI is calculated from the file name.

- **int raptor\_serialize\_start\_to\_string(raptor\_serializer\*** *rdf\_serializer***, raptor\_uri \****uri***, void \*\****string\_p***, size\_t \****length\_p***)**

  Start to serialize content to a string.  *string\_p* must point to a void\* pointer that will be used at the end of serializing to store the newly allocated string.  *length\_p* if not NULL, it will be used to store the length of the new string. The serializing is done with optional base URI *uri* however some syntaxes may refuse to serialize without a base URI, such as RDF/XML.

- **int raptor\_serialize\_start\_to\_file\_handle(raptor\_serializer\*** *rdf\_serializer***, raptor\_uri \****uri***, FILE \****handle***)**

  Start to serialize content to the already open C Standard I/O FILE\* *handle* with the base URI *uri*, which is optional and may be NULL.  Note that some syntaxes may refuse to serialize without a base URI, such as RDF/XML.

- **int raptor\_serialize\_statement(raptor\_serializer\*** *rdf\_serializer***, const raptor\_statement \****statement***)**

  Serialize a single *statement* using the serializer.

- **int raptor\_serialize\_end(raptor\_serializer\*** *rdf\_serializer***)**

  End the serializing.  This may close and delete resources used in serializing.  No more calls to raptor\_serialize\_statement or raptor\_serialize\_end may be done at this point.

- **raptor\_iostream\* raptor\_serializer\_get\_iostream(raptor\_serializer \****serializer***)**

  Return a pointer to the raptor\_iostream\* used by the serializer.

- **int raptor\_serializer\_set\_namespace(raptor\_serializer\*** *serializer***, raptor\_uri \****uri***, const char \****prefix***)**

  Set a suggested namespace URI/prefix mapping for use in serializing.

## SERIALIZER UTILITY METHODS

- **void raptor\_serializer\_set\_error\_handler(raptor\_serializer\*** *serializer***, void \****user\_data***, raptor\_message\_handler** *handler***)**

  Set the serializer non-fatal error handler callback.

- **void raptor\_serializer\_set\_warning\_handler(raptor\_serializer\*** *serializer***, void \****user\_data***, raptor\_message\_handler** *handler***)**

  Set the serializer warning message handler callback.

- **raptor\_locator\* raptor\_serializer\_get\_locator(raptor\_serializer\*** *rdf\_serializer***)**

  Return the current raptor\_locator object for the serializer. This is a public structure defined in raptor.h that can be used directly, or formatted via raptor\_print\_locator.

- **int raptor\_serializer\_set\_feature(raptor\_serializer \****serializer***, raptor\_feature** *feature***, int** *value***)**

  Set a serializer feature *feature* to a particular *value*. Returns non 0 on failure or if the feature is unknown. The current defined serializer features are:\
     *Feature                                 Values*\
     **RAPTOR\_FEATURE\_RELATIVE\_URIS**            Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_WRITE\_BASE\_URI**           Boolean (non 0 true)\
     **RAPTOR\_FEATURE\_START\_URI**                URI String\
     **RAPTOR\_FEATURE\_BNODE\_BORDER**             String\
     **RAPTOR\_FEATURE\_BNODE\_FILL**               String\
     **RAPTOR\_FEATURE\_JSON\_CALLBACK**            String\
     **RAPTOR\_FEATURE\_JSON\_EXTRA\_DATA**          String\
     **RAPTOR\_FEATURE\_LITERAL\_BORDER**           String\
     **RAPTOR\_FEATURE\_LITERAL\_FILL**             String\
     **RAPTOR\_FEATURE\_RESOURCE\_BORDER**          String\
     **RAPTOR\_FEATURE\_RESOURCE\_FILL**            String\
     **RAPTOR\_FEATURE\_RSS\_TRIPLES**              String\
     **RAPTOR\_FEATURE\_ATOM\_ENTRY\_URI**           String

If the *relative\_uris* feature is true (default false) then when serialising, preference is given to generating relative URIs where possible.

If the *write\_base\_uri* feature is true (default true) then the atom, rdfxml, rdfxml-abbrev and turtle serializers will write an @base or xml:base directive in the output.

If the *start\_uri* feature is set to a URI it is used by the serializer to start serializing from.

If the *bnode\_border* feature is set, the DOT serializer uses it as the bnode border colour.

If the *bnode\_fill* feature is set, the DOT serializer uses it as the bnode fill colour.

If the *json\_callback* feature is set, the JSON serializers use it as the name of the callback to wrap the outer JSON object.

If the *json\_extra\_data* feature is set, the JSON serializers use it as extra data inside the outer JSON object.

If the *literal\_border* feature is set, the DOT serializer uses it as the literal border colour.

If the *literal\_fill* feature is set, the DOT serializer uses it as the literal fill colour.

If the *resource\_border* feature is set, the DOT serializer uses it as the resource border colour.

If the *resource\_fill* feature is set, the DOT serializer uses it as the resource fill colour.

If the *rss\_triples* feature is set to the string "rdf-xml" for the rss-1.0 serializer or "atom-triples" for the atom serializer, it writes extra rdf triples into the serialized output.

If the *atom\_entry\_uri* feature is set to a URI string, it is used to trigger generation of an atom entry document for the atom serializer.

- **int raptor\_serializer\_get\_feature(raptor\_serializer\*** *serializer***, raptor\_feature** *feature***)**

  Get serializer features, the allowed *feature* values are available

- **raptor\_world\* raptor\_serializer\_get\_world(raptor\_serializer\*** *rdf\_serializer***)**

  Get the world object for the given *rdf\_serializer*.

## SERIALIZER UTILITY FUNCTIONS

- **int raptor\_serializers\_enumerate(const unsigned** *int counter***, const char \*\****name***, const char \*\****label***, const char \*\****mime\_type***, const unsigned char \*\****uri\_string***)**

  Return the serializer name/label for a serializer with a given integer counter, returning non-zero if no such parser at that offset exists.  The counter should start from 0 and be incremented by 1 until the function returns non-zero.

- **int raptor\_serializer\_syntax\_name\_check(const char \****name***)**

  Check *name* is a known serializer syntax name.

## URI CLASS

Raptor has a raptor\_uri class must be used for manipulating and passing URI references.  The default internal implementation uses char\* strings for URIs, manipulating them and constructing them. This URI implementation can be replaced by any other that provides the equivalent functionality, using the **raptor\_uri\_set\_handler** function.

## URI CONSTRUCTORS

There a several constructors for raptor\_uri to build them from char\* strings and existing raptor\_uri objects.

- **raptor\_uri\* raptor\_new\_uri(const unsigned char\*** *uri\_string***)**

  Create a raptor URI from a string URI-reference *uri\_string*.

- **raptor\_uri\* raptor\_new\_uri\_from\_uri\_local\_name(raptor\_uri\*** *uri***, const unsigned char\*** *local\_name***)**

  Create a raptor URI from a string URI-reference *local\_name* relative to an existing URI-reference.  This performs concatenation of the  *local\_name* to the *uri* and not relative URI resolution, which is done by the raptor\_new\_uri\_relative\_to\_base constructor.

- **raptor\_uri\* raptor\_new\_uri\_relative\_to\_base(raptor\_uri\*** *base\_uri, const unsigned char\* uri\_string***)**

  Create a raptor URI from a string URI-reference *uri\_string* using relative URI resolution to the *base\_uri*.

- **raptor\_uri\* raptor\_new\_uri\_from\_id(raptor\_uri\*** *base\_uri***, const unsigned char\*** *id***)**

  Create a raptor URI from a string RDF ID *id* concatenated to the *base\_uri* base URI.

- **raptor\_uri\* raptor\_new\_uri\_for\_rdf\_concept(const char\*** *name***)**

  Create a raptor URI for the RDF namespace concept *name*.

- **raptor\_uri\* raptor\_new\_uri\_for\_xmlbase(raptor\_uri\*** *old\_uri***))**

  Create a raptor URI suitable for use with xml:base (throw away fragment)

## URI DESTRUCTOR

- **void raptor\_free\_uri(raptor\_uri\*** *uri***)**

  Destroy a raptor URI object.

## URI METHODS

- **int raptor\_uri\_equals(raptor\_uri\*** *uri1***, raptor\_uri\*** *uri2***)**

  Return non-zero if the given URIs are equal.

- **raptor\_uri\* raptor\_uri\_copy(raptor\_uri\*** *uri***)**

  Return a copy of the given raptor URI *uri*.

- **unsigned char\* raptor\_uri\_as\_counted\_string(raptor\_uri \*uri, size\_t\* len\_p)**

  - **unsigned char\* raptor\_uri\_as\_string(raptor\_uri\*** *uri***)**

  Return a shared pointer to a string representation of the given raptor URI *uri*.  This string is shared and must not be freed (otherwise see the **raptor\_uri\_to\_\*** methods below).  If **raptor\_uri\_as\_counted\_string** is used, the length of the returned string is stored in \**len\_p* if not NULL.

- **unsigned char\* raptor\_uri\_to\_counted\_string(raptor\_uri \****uri***, size\_t \****len\_p***)**

  - **unsigned char\* raptor\_uri\_to\_string(raptor\_uri \****uri***)**

  Return a to a newly alloced string representation of the given raptor URI *uri*.  This string must be freed by the caller using **raptor\_free\_memory**.  If **raptor\_uri\_to\_counted\_string** is used, the length of the returned string is stored in \**len\_p* if not NULL.

- **unsigned char\* raptor\_uri\_to\_relative\_counted\_uri\_string(raptor\_uri \****base\_uri***, raptor\_uri \****reference\_uri***, size\_t \****length\_p***)**

  - **unsigned char\* raptor\_uri\_to\_relative\_uri\_string(raptor\_uri \****base\_uri***, raptor\_uri \****reference\_uri***)**

  Return a new relative URI string of a URI *reference\_uri against* *a base URI base\_uri.  The returned string must be freed*  *with* **raptor\_free\_memory***.* *If* **raptor\_uri\_to\_relative\_counted\_string** *is used, the length of* *the returned string is stored in \*len\_p if not NULL.*

- **void raptor\_uri\_print(const raptor\_uri\*** *uri***, FILE \****stream***)**

  *Print URI uri to the file handle stream.*

- **int raptor\_iostream\_write\_uri(raptor\_iostream\*** *iostr***, raptor\_uri\*** *uri***)**

  *Write the raptor\_uri uri to the iostream ostr.*

## URI UTILITY FUNCTIONS

- **void raptor\_uri\_resolve\_uri\_reference (const unsigned char\*** *base\_uri***, const unsigned char\*** *reference\_uri***, char unsigned\*** *buffer***, size\_t** *length***)**

  *This is a standalone function that resolves the relative URI* *reference\_uri against the base URI base\_uri* *according to the URI resolution rules in RFC2396.* *The resulting URI is stored in buffer which is of length* *bytes.  If this is too small, no work will be done.*

- **char \*raptor\_uri\_filename\_to\_uri\_string(const unsigned char\*** *filename***)**

  *This is a standalone function that turns a local filename (Windows* *or Unix style as appropriate for platform) into a URI string (file).*\
    *The returned string must be freed by the caller. Some systems* *require memory allocated in a library to be deallocated inside that* *library in which case* **raptor\_free\_memory** *may be used.*

- **char \*raptor\_uri\_uri\_string\_to\_filename(const unsigned char\*** *uri\_string***)**

  - **char \*raptor\_uri\_uri\_string\_to\_filename(const unsigned char\*** *uri\_string***, unsigned char \*\****fragment\_p***)**

  *These are standalone functions that turn a URI string that* *represents a local filename (file:) into a filename, with optional* *URI fragment.  If fragment\_p is not NULL it points to the* *location to store a newly allocated string containing the fragment.* *The returned strings must be freed by the caller.  Some systems* *require memory allocated in a library to be deallocated inside that* *library in which case* **raptor\_free\_memory** *may be used.*

- **int raptor\_uri\_is\_file\_uri(const unsigned char\*** *uri\_string***)**

  *DEPRECATED in 1.4.9.* *Returns non-zero if the given URI string represents a filename.* *Use* **raptor\_uri\_uri\_string\_is\_file\_uri** *in preference.*

- **int raptor\_uri\_uri\_string\_is\_file\_uri(const unsigned char\*** *uri\_string***)**

  *Returns non-zero if the given URI string represents a filename.*

## URI CLASS IMPLEMENTATION

- **void raptor\_uri\_set\_handler(const raptor\_uri\_handler \****handler***, void \****context***)**

  *Change the URI class implementation to the functions provided by the* *handler* *URI implementation.* *The* *context* *user data is passed in to the handler URI implementation calls.*

- **void raptor\_uri\_get\_handler(raptor\_uri\_handler \*\****handler***, void \*\****context***)**

  *Return the current raptor URI class implementation* *handler* *and* *context*

## WWW CLASS

*This is a small wrapper class around existing WWW libraries in* *order to provide HTTP GET or better URI retrieval for Raptor.  It* *is not intended to be a general purpose WWW retrieval interface.*

## WWW CLASS INITIALISATION AND CLEANUP

- **void raptor\_www\_init(void)**

  - **void raptor\_www\_finish(void)**

  *Initialise or terminate the raptor\_www infrastructure.  raptor\_www\_init* *and raptor\_finish are called by raptor\_init and raptor\_finish* *respecitively, otherwise must be called once each.*

- NOTE

  *Several of the WWW library implementations require once-only* *initialisation and termination functions to be called, however raptor* *cannot determine whether this is already done before the library* *is initialised in* **raptor\_www\_init** *or terminated in*  **raptor\_www\_finish***, so always performs it.* *This can be changed by* **raptor\_www\_no\_www\_library\_init\_finish***.*

- **void raptor\_www\_no\_www\_library\_init\_finish(void)**

  *If this is called before* **raptor\_www\_init***, it will not call* *the underlying WWW library global initialise or terminate functions.* *The application code must perform both operations.*

-

  *For example with curl, after this function is called, neither* **curl\_global\_init** *nor* **curl\_global\_cleanup** *will be called* *during* **raptor\_www\_init** *or* **raptor\_www\_finish** *respectively.*

## WWW CONSTRUCTORS

- **raptor\_www \*raptor\_www\_new(void)**

  - **raptor\_www \*raptor\_www\_new\_with\_connection(void\*** *connection***)**

  *Create a raptor WWW object capable of URI retrieval.  If connection* *is given, it must match the connection object of the underlying WWW* *implementation.  At present, this is only for libcurl, and allows you* *to re-use an existing curl handle, or use one which has been set up* *with some desired qualities.*

## WWW DESTRUCTOR

- **void raptor\_www\_free(raptor\_www \****www***)**

  *Destroy a raptor WWW object.*

## WWW METHODS

- **void raptor\_www\_set\_user\_agent(raptor\_www \****www***, const char \****user\_agent***)**

  *Set the HTTP User-Agent header value.*

- **int raptor\_www\_set\_http\_cache\_control(raptor\_www\*** *www***, const char\*** *cache\_control***)**

  *Set the HTTP Cache-Control header value.*

- **void raptor\_www\_set\_proxy(raptor\_www \****www***, const char \****proxy***)**

  *Set the HTTP proxy - usually a string of the form http://server:port*

- **raptor\_www\_set\_write\_bytes\_handler(raptor\_www \****www***, raptor\_www\_write\_bytes\_handler** *handler***, void \****user\_data***)**

  *Set the handler to receive bytes written by the raptor\_www implementation.*

- **void raptor\_www\_set\_content\_type\_handler(raptor\_www \****www***, raptor\_www\_content\_type\_handler** *handler***, void \****user\_data***)**

  *Set the handler to receive the HTTP Content-Type value, when/if* *discovered during retrieval by the raptor\_www implementation.*

- **void raptor\_www\_set\_http\_accept(raptor\_www \****www***, const char \****value***)**

  *Set the WWW HTTP Accept: header to value.  If value is* *NULL, an empty header is sent.*

- **void raptor\_www\_set\_error\_handler(raptor\_www \*www, raptor\_message\_handler** *error\_handler***, void \****error\_data***)**

  *Set the error handler routine for the raptor\_www class.  This takes the* *same arguments as the raptor\_parser error, warning handler methods.*

- **void raptor\_www\_set\_uri\_filter(raptor\_www\*** *www***, raptor\_uri\_filter\_func** *filter***, void\*** *user\_data***)**

  *Set the URI filter function filter for URIs retrieved by* *the raptor\_www object.*

- **void\* raptor\_www\_get\_connection(raptor\_www \****www***)**

  *Return the underlying WWW library connection object.  For example,* *for libcurl this is the curl\_handle.*

- **void raptor\_www\_set\_connection\_timeout(raptor\_www\*** *www***, int** *timeout***)**

  *Set the WWW connection timeout in seconds.*

- **raptor\_uri\* raptor\_www\_get\_final\_uri(raptor\_www\*** *www***)**

  *Get the final URI from a WWW retrieval, which may include redirections.*

## WWW ACTION METHODS

- **int raptor\_www\_fetch(raptor\_www \*www, raptor\_uri \*uri)**

  *Retrieve the given URL, returning non zero on failure.*

- **int raptor\_www\_fetch\_to\_string(raptor\_www \*www, raptor\_uri \*uri, void \*\*string\_p, size\_t \*length\_p, void \*(\*malloc\_handler)(size\_t size))**

  *Retrieve the given URL to a string.  string\_p must point* *to a void\* pointer that will be used to store* *the newly allocated string.  length\_p if not NULL, it will* *be used to store the length of the new string.*

- **void raptor\_www\_abort(raptor\_www \*www, const char \*reason)**

  *Abort an ongoing raptor WWW operation. Typically used within one of the* *raptor WWW handlers.*

## QNAME CLASS

*This is a class for handling XML QNames consisting* *of the pair of (a URI from a namespace, a local name) along with*  *an optional value -- useful for XML attributes.  This is used with* *the raptor\_namespace\_stack and raptor\_namespace classes to handle a* *stack of raptor\_namespace that build on raptor\_qname.*

## QNAME CONSTRUCTORS

*There are two constructors for raptor\_qname to build qnames* *with optional values on a stack of names.*

- **raptor\_qname\* raptor\_new\_qname(raptor\_namespace\_stack \****nstack***, const unsigned char \****name***, const unsigned char \****value***, raptor\_simple\_message\_handler** *error\_handler***, void \****error\_data***)**

  *Create a raptor QName name (a possibly :-separated name) with* *name to be resolved against the given nstack namespace stack.* *An optional value can be given, and if there is an error,* *the error\_handler* **and** *error\_data* **will be used to invoke** **the callback.**

- **raptor\_qname\* raptor\_new\_qname\_from\_namespace\_local\_name (raptor\_namespace \****ns***, const unsigned char \****local\_name***, const unsigned char \****value***)**

  **Create a raptor QName using the namespace name of the** **raptor\_namespace** *ns* **and the local name** *local\_name***, along** **with optional value** *value***.  Errors are reported using** **the error handling and data of the namespace.**

- **raptor\_qname\* raptor\_qname\_copy(raptor\_qname \****qname***)**

  **Create a raptor QName from an existing one, returning NULL on failure.**

## QNAME DESTRUCTOR

- **void raptor\_free\_qname(raptor\_qname\*** *name***)**

  **Destroy a raptor qname object.**

## QNAME METHODS

- **int raptor\_qname\_equal(raptor\_qname\*** *name1***, raptor\_qname \****name2***)**

  **Return non-zero if the given QNames are equal.**

- **int raptor\_iostream\_write\_qname(raptor\_iostream\*** *iostr***, raptor\_qname \****qname***)**

  **Write the raptor\_qname** *qname* **to the iostream** *ostr***.**

- **const unsigned char\* raptor\_qname\_get\_local\_name(raptor\_qname\*** *name***)**

  **Get the local name of the QName.**

- **const unsigned char\* raptor\_qname\_get\_value(raptor\_qname\*** *name***)**

  **Get the value of the QName for an XML attribute QName.**

- **const unsigned char\* raptor\_qname\_get\_counted\_value(raptor\_qname\*** *name***, size\_t\*** *length\_p***)**

  **Get the value fo the QName along with the length (if** *length\_p* **is not NULL) for an XML attribute QName.**

- **unsigned char\* raptor\_qname\_to\_counted\_name(raptor\_qname\*** *qname***, size\_t\*** *length\_p***)**

  **Get the formatted QName as a newly allocated counted string (if** *length\_p* **is not NULL).**

## QNAME UTILITY FUNCTIONS

- **raptor\_uri\* raptor\_qname\_string\_to\_uri(raptor\_namespace\_stack \****nstack***, const unsigned char \****name***, size\_t** *name\_len***, raptor\_simple\_message\_handler** *error\_handler***, void \****error\_data***)**

  **Return the URI corresponding to the QName according to the RDF** **method; concatenating the namespace's name (URI) with the local** **name.  Takes the same arguments as raptor\_new\_qname but** **does not create a raptor\_qname object.**

- **raptor\_namespace\* raptor\_qname\_get\_namespace(raptor\_qname\*** *name***)**

  **Return the raptor\_namespace used by the QName.  Will never be NULL** **even for the default namespace in which case the URI of the returned** **namespace object will be NULL.**

## NAMESPACE CLASS

**An XML namespace class - each entry is on a stack and consists of a** **name (URI) and prefix.  The prefix or the name but not both may be** **empty.  If the prefix is empty, it defines the default prefix.  If** **the name is empty, it undefines the given prefix.**

## NAMESPACE CONSTRUCTORS

- **raptor\_namespace\* raptor\_new\_namespace(raptor\_namespace\_stack \****nstack***, const unsigned char \****prefix***, const unsigned char \****ns\_uri\_string***, int** *depth***)**

  - **raptor\_namespace\* raptor\_new\_namespace\_from\_uri(raptor\_namespace\_stack \****nstack***, const unsigned char \****prefix***, raptor\_uri\*** *ns\_uri***, int** *depth***)**

  **Create a new raptor\_namespace object on the given namespace stack** *nstack* **with prefix** *prefix* **and namespace name either** **from URI string** *ns\_uri\_string* **or from copying URI** *ns\_uri***.**

**If** *prefix* **is NULL, it defines the URI for the default namespace** **prefix.  If the namespace name (***ns\_uri\_string* **or** *ns\_uri***)** **is NULL, it undefines the given** *prefix* **in the current scope.** **Both prefix and URI may be NULL to undefine the default namespace.** *depth* **signifies the position of the namespace on the stack; 0** **is the bottom of the stack and generally the first depth for user** **namespace declarations.**

**Namespaces declared on the same** **depth (such as on the same XML element, typically) can be handily** **freed with** *raptor\_namespaces\_end\_for\_depth* **method on** **the namespace stack class.**

## NAMESPACE DESTRUCTOR

- **void raptor\_free\_namespace(raptor\_namespace \*ns)**

  **Destroy a raptor namespace object.**

## NAMESPACE METHODS

- **raptor\_uri\* raptor\_namespace\_get\_uri(const raptor\_namespace \*ns)**

  **Return the namespace name (URI) of the namespace.**

- **const unsigned char\* raptor\_namespace\_get\_prefix(const raptor\_namespace \*ns)**

  **Return the prefix of the namespace.**

- **const unsigned char\* raptor\_namespace\_get\_counted\_prefix(const raptor\_namespace\*** *ns***, size\_t\*** *length\_p***)**

  **Return the prefix of the namespace as a string with optional count stored in** **the variable address** *length\_p* **if it is not NULL.**

- **unsigned char \*raptor\_namespaces\_format(const raptor\_namespace \*ns, size\_t \*length\_p)**

  **Format the namespace as a string and return it as a new string, returning the** **length of the resulting string in** *length\_p* **if it is not NULL.** **The string format is suitable for emitting in XML to declare the** **namespace.**

- **int raptor\_iostream\_write\_namespace(raptor\_iostream\*** *iostr***, raptor\_namespace \****ns***)**

  **Write a formatted namespace declaration like xmlns... to an** **iostream** *iostr***.**

## NAMESPACE UTILITY FUNCTIONS

- **int raptor\_namespace\_copy(raptor\_namespace\_stack \*nstack, raptor\_namespace \*ns, int new\_depth)**

  **Copy the namespace from the current stack to the new one,** *nstack* **at depth** *new\_depth***.**

- **int raptor\_new\_namespace\_parts\_from\_string(unsigned char \****string***, unsigned char \*\****prefix***, unsigned char \*\****uri\_string***)**

  **Parse** *string* **with an XML-style namespace declaration like** **xmlns="", xmlns="uri", xmlns:prefix="" or xmlns:prefix="uri"** **into the strings pointed to by** *prefix* **string and a** *uri\_string***.** **Empty prefixes or namespace names return NULL pointers.  Returned** **strings must be freed by the caller using raptor\_free\_memory.**

## NAMESPACE STACK CLASS

**A stack of raptor\_namespace objects where the namespaces on top of the stack** **have wider scope and override earlier (lower) namespace declarations.** **Intended to match the XML namespace declaring semantics using** **xmlns attributes.**

## NAMESPACE STACK CONSTRUCTORS

- **raptor\_namespace\_stack\* raptor\_new\_namespaces(raptor\_uri\_handler \*uri\_handler, void \*uri\_context, raptor\_simple\_message\_handler error\_handler, void \*error\_data, int defaults)**

  - **int raptor\_namespaces\_init(raptor\_namespace\_stack \*nstack, raptor\_uri\_handler \*handler, void \*context, raptor\_simple\_message\_handler error\_handler, void \*error\_data, int defaults)**

  **Create or initialise a new raptor\_namespace\_stack object with the given URI and** **error handlers.  raptor\_namespaces\_new allocates new memory** **for the namespace stack and raptor\_namespaces\_init initialises an** **existing declared** *nstack***, which could be statically allocated.** **Note that raptor\_uri\_get\_handler can be useful to return the** **current raptor URI handler/context.  The** *defaults* **argument** **describes which default namespaces are declared in the empty stack.** **At present, 0 is none, 1 for just the XML namespace and 2 is for** **a typical set of namespaces used for RDF, RDFS, Dublin Core, OWL, ...** **that may vary over time.**

-

  **In versions 1.4.16 or newer this returns an integer result, non-0 on** **failure.**

## NAMESPACE STACK DESTRUCTORS

- **void raptor\_free\_namespaces(raptor\_namespace\_stack \*nstack)**

  **Destroy a namespace stack object, freeing the** *nstack* **(goes with raptor\_new\_namespaces).**

- **void raptor\_namespaces\_clear(raptor\_namespace\_stack \*nstack)**

  **Clear a statically allocated namespace stack; does not free the** *nstack***.** **(goes with raptor\_namespaces\_init).**

## NAMESPACE STACK METHODS

- **void raptor\_namespaces\_start\_namespace(raptor\_namespace\_stack \*nstack, raptor\_namespace \*nspace)**

  **Start the given** *nspace* on the stack, at the depth already defined.

- **int raptor\_namespaces\_start\_namespace\_full(raptor\_namespace\_stack \*nstack, const unsigned char \*prefix, const unsigned char \*nspace, int depth)**

  Create a new raptor\_namespace and start it on the stack. See **raptor\_new\_namespace** for the meaning of the argumens.

- **void raptor\_namespaces\_end\_for\_depth(raptor\_namespace\_stack \*nstack, int depth)**

  End (and free) all namespaces on the stack at the given *depth*.

- **raptor\_namespace\* raptor\_namespaces\_get\_default\_namespace (raptor\_namespace\_stack \*nstack)**

  Return the current default raptor\_namespace of the namespace stack or NULL if there is none.

- **raptor\_namespace\* raptor\_namespaces\_find\_namespace\_by\_uri(raptor\_namespace\_stack \****nstack***, raptor\_uri \****ns\_uri***)**

  Find the first namespace on the stack with the given uri *ns\_uri* or NULL if there is none.

- **raptor\_namespace \*raptor\_namespaces\_find\_namespace\_by\_uri(raptor\_namespace\_stack \*nstack, const unsigned char \*prefix, int prefix\_length)**

  Find the first namespace on the stack with the given namespace *prefix* or NULL if there is none.

- **int raptor\_namespaces\_namespace\_in\_scope(raptor\_namespace\_stack \*nstack, const raptor\_namespace \*nspace)**

  Return non-zero if the raptor\_namespace *nspace* is declared on the stack; i.e. in scope if this is a stack of XML namespaces.

## NAMESPACE STACK UTILITY FUNCTIONS

- **raptor\_qname\* raptor\_namespaces\_qname\_from\_uri(raptor\_namespace\_stack\*** *nstack***, raptor\_uri\*** *uri***, int** *xml\_version***)**

  Create a raptor QName from the URI *uri* if the URI is squal one of the namespace URIs on the namespace stack *nstack* URIs concatenated to a legal XML name for the given XML version.  URIs are created and errors are reported using the namespace stack fields. Fails if it cannot be legally described with any of the namespaces.

## SEQUENCE CLASS

A class for ordered sequences of items, adding at either end of the sequence.  The method names should be familiar to Perl users.

## SEQUENCE CONSTRUCTOR

- **raptor\_sequence\* raptor\_new\_sequence(raptor\_sequence\_free\_handler\*** *free\_handler***, raptor\_sequence\_print\_handler\*** *print\_handler***)**

  Create a new empty sequence, with optional handler for freeing elements (as used by **raptor\_free\_sequence** and printing out elements (used by **raptor\_sequence\_print**).

## SEQUENCE DESTRUCTOR

- **void raptor\_free\_sequence(raptor\_sequence\*** *seq***)**

  Destoy a sequence object, freeing any items if the free handler was defined in the constructor.

## SEQUENCE METHODS

- **int raptor\_sequence\_size(raptor\_sequence\*** *seq***)**

  Return the number of items in the sequence.

- **int raptor\_sequence\_set\_at(raptor\_sequence\*** *seq***, int** *idx***, void \*data)**

  Set the sequence item at index *idx* to the value *data*, extending it if necessary.

- **int raptor\_sequence\_push(raptor\_sequence\*** *seq***, void \****data***)**

  Add item *data* to the end of the sequence.

- **int raptor\_sequence\_shift(raptor\_sequence\*** *seq***, void \****data***)**

  Add item *data* to the start of the sequence.

- **void\* raptor\_sequence\_get\_at(raptor\_sequence\*** *seq***, int** *idx***)**

  Get the sequence item at index *idx* or NULL if no such index exists.

- **void\* raptor\_sequence\_pop(raptor\_sequence\*** *seq***)**

  Remove and return an item from the end of the sequence, or NULL if is empty.

- **void\* raptor\_sequence\_unshift(raptor\_sequence\*** *seq***)**

  Remove and return an item from the start of the sequence, or NULL if is empty.

- **void raptor\_sequence\_sort(raptor\_sequence\*** *seq***, int(\****compare***)(const void \*, const void \*))**

  Sort the sequence using the given comparison function *compare* which is passed to [qsort(3)](/qsort/3.md) internally.

- **int raptor\_compare\_strings(const void \****a***, const void \****b***)**

  Helper function useful with **raptor\_sequence\_sort**.

- **void raptor\_sequence\_set\_print\_handler(raptor\_sequence \****seq***, raptor\_sequence\_print\_handler \****print\_handler***)**

  Set the print handler for the sequence, an alternative to setting it in the constructor.

- **void raptor\_sequence\_print\_string(char \****data***, FILE \****fh***)**

  Helper print handler function useful for printing out sequences of strings.

- **void raptor\_sequence\_print\_uri(char \****data***, FILE \****fh***)**

  Helper print handler function useful for printing out sequences of raptor\_uri\* objects.

- **void raptor\_sequence\_print(raptor\_sequence\*** *seq***, FILE\*** *fh***)**

  Print out the sequence in a debug format to the given file handler *fh*.  NOTE: The exact format is not guaranteed to remain  the same between releases.

- **int raptor\_sequence\_join(raptor\_sequence\*** *dest***, raptor\_sequence \****src***)**

  Join two sequences moving all items from sequence *src* to the end of sequence *dest*.  After this operation, sequence *src* will be empty (zero size) but will have the same item capacity as before.

- **void\* raptor\_sequence\_delete\_at(raptor\_sequence\*** *seq***, int** *idx***)**

  Remove an item from position *idx* in the sequence, returning it.

## STRINGBUFFER CLASS

A class for growing strings, small chunks at a time.

## STRINGBUFFER CONSTRUCTOR

- **raptor\_stringbuffer\* raptor\_new\_stringbuffer(void)**

  Create a new stringbuffer.

## STRINGBUFFER DESTRUCTOR

- **void raptor\_free\_stringbuffer(raptor\_stringbuffer\*** *stringbuffer***)**

  Destroy a stringbuffer.

## STRINGBUFFER METHODS

- **int raptor\_stringbuffer\_append\_counted\_string(raptor\_stringbuffer\*** *stringbuffer***, const unsigned char \****string***, size\_t** *length***, int** *do\_copy***)**

  Append a *string* of *length* bytes to a stringbuffer, copying it only if *do\_copy* is non-0.

- **int raptor\_stringbuffer\_append\_string(raptor\_stringbuffer\*** *stringbuffer***, const unsigned char\*** *string***, int** *do\_copy***)**

  Append a *string* to a stringbuffer, copying it only if *do\_copy* is non-0.

- **int raptor\_stringbuffer\_append\_decimal(raptor\_stringbuffer\*** *stringbuffer***, int** *integer***)**

  Append a formatted decimal *integer* to a stringbuffer.

- **int raptor\_stringbuffer\_append\_stringbuffer(raptor\_stringbuffer\*** *stringbuffer***, raptor\_stringbuffer\*** *append***)**

  Append a stringbuffer *append* to a stringbuffer.  The append stringbuffer is emptied but not destroyed.

- **int raptor\_stringbuffer\_prepend\_counted\_string(raptor\_stringbuffer\*** *stringbuffer***, const unsigned char\*** *string***, size\_t** *length***, int** *do\_copy***)**

  Prepend a *string* of *length* bytes to the start of a stringbuffer, copying it only if *do\_copy* is non-0.

- **int raptor\_stringbuffer\_prepend\_string(raptor\_stringbuffer\*** *stringbuffer***, const unsigned char\*** *string***, int** *do\_copy***)**

  Prepend a *string* to the start of a stringbuffer, copying it only if *do\_copy* is non-0.

- **unsigned char \* raptor\_stringbuffer\_as\_string(raptor\_stringbuffer\*** *stringbuffer***)**

  Return the stringbuffer as a single string.  The string is shared and should be copied if needed.

- **size\_t raptor\_stringbuffer\_length(raptor\_stringbuffer\*** *stringbuffer***)**

  Return the length of the stringbuffer.

- **int raptor\_stringbuffer\_copy\_to\_string(raptor\_stringbuffer\* stringbuffer, unsigned char \****string***, size\_t** *len***gth)**

  Copy the stringbuffer into a single string buffer *string* of size *length*.  Returns non-0 on failure.

## IOSTREAM CLASS

This class provides an I/O stream that can write to filenames, FILE\*, strings and user-defined output via callbacks.

## IOSTREAM CONSTRUCTOR

- **raptor\_iostream\* raptor\_new\_iostream\_from\_handler2(void\*** *context***, const raptor\_iostream\_handler2 \****handler***)**

  Create a new raptor read or write iostream from a user-defined raptor\_iostream\_handler2 *handler* that is called with the passed-in *context* for the write operations.

- **raptor\_iostream\* raptor\_new\_iostream\_from\_handler(void\*** *context***, const raptor\_iostream\_handler \****handler***)**

  DEPRECATED in 1.4.17 - use **raptor\_new\_iostream\_from\_handler2()** with the new handler format. Create a new raptor read iostream from a user-defined raptor\_iostream\_handler *handler* that is called with the passed-in *context* for the write operations.

- **raptor\_iostream\* raptor\_new\_iostream\_to\_sink(void)**

  Create a new raptor write iostream that discards all written output.

- **raptor\_iostream\* raptor\_new\_iostream\_to\_filename(const char \****filename***)**

  Create a new raptor write iostream that creates and writes to a new file *filename*.

- **raptor\_iostream\* raptor\_new\_iostream\_to\_file\_handle(FILE \****handle***)**

  Create a new raptor write iostream that creates and writes to an existing, already opened, C Standard I/O handle FILE\* *handle*.

- **raptor\_iostream\* raptor\_new\_iostream\_to\_string(void \*\****string\_p***, size\_t \****length\_p***, void \*(\****malloc\_handler***)(size\_t size))**

  Create a new raptor write iostream which creates a new string once raptor\_free\_iostream is called.  The new string pointer is written in *string*, the length in *length\_p* (if not NULL) and the memory allocation is made using the *malloc\_handler*, or if NULL, raptor's default memory allocator.

- **raptor\_iostream\* raptor\_new\_iostream\_from\_sink(void)**

  Create a new raptor read iostream that is immediately finished and returns end of file.

- **raptor\_iostream\* raptor\_new\_iostream\_from\_filename(const char \****filename***)**

  Create a new raptor read iostream from an existing file *filename*.

- **raptor\_iostream\* raptor\_new\_iostream\_from\_file\_handle(FILE \****handle***)**

  Create a new raptor read iostream from an already opened, C Standard I/O handle FILE\* *handler*.

- **raptor\_iostream\* raptor\_new\_iostream\_from\_string(void \****string***, size\_t** *length***)**

  Create a new raptor read iostream reading from an existing *string* of *length* bytes.

## IOSTREAM DESTRUCTOR

- **void raptor\_free\_iostream(raptor\_iostream \****iostr***)**

  Destroy a Raptor iostream object.

## IOSTREAM METHODS

- **int raptor\_iostream\_write\_bytes(raptor\_iostream \****iostr***, const void \****ptr***, size\_t** *size***, size\_t** *nmemb***)**

  Write a counted set of elements to an iostream. Inmemb *is the* *count of elements of size size, starting at memory ptr.* *Similar to [fwrite(3)](/fwrite/3.md) and [write(2)](/write/2.md).*

- **int raptor\_iostream\_write\_byte(raptor\_iostream \****iostr***, const int** *byte***)**

  *Write a single byte an iostream.  Similar to [fputc(3)](/fputc/3.md).*

- **void raptor\_iostream\_write\_end(raptor\_iostream \****iostr***)**

  *Finish writing to an iostream.*

- **int raptor\_iostream\_write\_string(raptor\_iostream \****iostr***, const void \****string***)**

  *Write a NUL-terminated string to an iostream.  Similar to [fputs(3)](/fputs/3.md).*

- **int raptor\_iostream\_write\_counted\_string(raptor\_iostream \****iostr***, const void \****string***, size\_t** *len***)**

  *Write a string of length len to an iostream.*

- **unsigned long raptor\_iostream\_tell(raptor\_iostream \****iostr***)**

  *Return the byte offset into the iostream.*

- **size\_t raptor\_iostream\_get\_bytes\_written\_count(raptor\_iostream \****iostr***)**

  *DEPRECATED in 1.4.17 for* **raptor\_iostream\_tell()***.* *Return the number of bytes written so far to the iostream.*

- **int raptor\_iostream\_write\_decimal(raptor\_iostream \****iostr***, int** *integer***)**

  *Write a decimal formatted integer integer to the iostream.*

- **int raptor\_iostream\_format\_hexadecimal(raptor\_iostream \****iostr***, unsigned int** *integer***, int** *width***)**

  *Write a hexadecimal formatted unsigned integer to the iostream,* *left-padded with '0's to width* columns.

- **int raptor\_iostream\_write\_stringbuffer(raptor\_iostream\*** *iostr***, raptor\_stringbuffer \****sb***)**

  Write the stringbuffer to an iostream *iostr*.

- **int raptor\_iostream\_read\_bytes(raptor\_iostream\*** *iostr***, void \****ptr***, size\_t** *size***, size\_t** *nmemb***)**

  Read bytes from the iostream into buffer *ptr* up to *nmemb* elements of size *size*.

- **int raptor\_iostream\_read\_eof(raptor\_iostream \****iostr***)**

  Return non-0 if the iostream is finished.

## XML SAX2 READER CLASS

This class provides the functionality to generate SAX2 events from parsing XML content, including XML namespace support.

## XML SAX2 CONSTRUCTOR

- **raptor\_sax2\* raptor\_new\_sax2(void \****user\_data***, raptor\_error\_handlers\*** *error\_handlers***)**

  Create a new SAX2 XML reader with the given error handler object.

## XML WRITER DESTRUCTOR

- **void raptor\_free\_sax2(raptor\_sax2 \****sax2***)**

  Destroy a SAX2 XML reader object.

## SAX2 SET HANDLER METHODS

- **void raptor\_sax2\_set\_start\_element\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_start\_element\_handler** *handler***)**

  Set the SAX2 start element *handler*.

- **void raptor\_sax2\_set\_end\_element\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_end\_element\_handler** *handler***)**

  Set the SAX2 end element *handler*.

- **void raptor\_sax2\_set\_characters\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_characters\_handler** *handler***)**

  Set the SAX2 character data element *handler*.

- **void raptor\_sax2\_set\_cdata\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_cdata\_handler** *handler***)**

  Set the SAX2 CDATA section element *handler*.

- **void raptor\_sax2\_set\_comment\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_comment\_handler** *handler***)**

  Set the SAX2 XML comment *handler*.

- **void raptor\_sax2\_set\_unparsed\_entity\_decl\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_unparsed\_entity\_decl\_handler** *handler***)**

  Set the SAX2 XML unparsed entity declaration *handler*.

- **void raptor\_sax2\_set\_external\_entity\_ref\_handler(raptor\_sax2 \****sax2***, raptor\_sax2\_external\_entity\_ref\_handler** *handler***)**

  Set the SAX2 XML external entity reference *handler*.

- **void raptor\_sax2\_set\_namespace\_handler(raptor\_sax2 \****sax2***, raptor\_namespace\_handler** *handler***)**

  Set the SAX2 XML namespace declaration *handler* when an XML namespace is declared.

## SAX2 PARSING METHODS

- **void raptor\_sax2\_parse\_start(raptor\_sax2 \****sax2***, raptor\_uri \****base\_uri***)**

  Start a SAX2 parse of XML content with the base URI *uri*.

- **int raptor\_sax2\_parse\_chunk(raptor\_sax2 \****sax2***, const unsigned char \****buffer***, size\_t** *len***, int** *is\_end***)**

  Parse the XML content in *buffer* of size *len* returning SAX2 events via handlers.  If *is\_end* is non-zero, it indicates the end of the parsing.  This method can only be called after **raptor\_sax2\_parse\_start()**.

## SAX2 SCOPE METHODS

- **const unsigned char\* raptor\_sax2\_inscope\_xml\_language(raptor\_sax2 \****sax2***)**

  Get the current in-scope XML language (xml:lang) value.

- **raptor\_uri\* raptor\_sax2\_inscope\_base\_uri(raptor\_sax2 \****sax2***)**

  Get the current in-scope Base URI (xml:base or document or protocol) value.

## XML ELEMENT CLASS

This class provides an XML element that can be used with the XML Writer Class to generate XML documents.

## XML ELEMENT CONSTRUCTORS

- **raptor\_xml\_element\* raptor\_new\_xml\_element(raptor\_qname\*** *name***, const unsigned char\*** *xml\_language***, raptor\_uri\*** *xml\_base***)**

  Create a new XML element with the element name *name* in the context of xml:lang *xml\_language* and base URI *xml\_base*.

- **raptor\_xml\_element\* raptor\_new\_xml\_element\_from\_namespace\_local\_name(raptor\_namespace \****ns***, const unsigned char \****name***, const unsigned char\*** *xml\_language***, raptor\_uri\*** *xml\_base*

  Create a new XML element based on the given XML *namespace* and *localname* in the context of xml:lang *xml\_languageFP and base URI* *xml\_base.*

## XML ELEMENT DESTRUCTOR

- **void raptor\_free\_xml\_element(raptor\_xml\_element \****element***)**

  *Destroy a XML element object.*

## XML ELEMENT METHODS

- **raptor\_qname\* raptor\_xml\_element\_get\_name(raptor\_xml\_element\*** *xml\_element***)**

  *Get the XML element QName of XML element xml\_element.*

- **void raptor\_xml\_element\_set\_attributes(raptor\_xml\_element\*** *xml\_element***, raptor\_qname \*\****attributes***, int** *count***)**

  *Set the attributes on XML element xml\_element to the* *array of QNames in array attributes of size count.*

- **raptor\_qname\*\* raptor\_xml\_element\_get\_attributes(raptor\_xml\_element\*** *xml\_element***)**

  *Get the attributes of an XML element xml\_element as an* *array of QNames.  As set by* **void raptor\_xml\_element\_set\_attributes***.*

- **int raptor\_xml\_element\_get\_attributes\_count(raptor\_xml\_element\*** *xml\_element***)**

  *Get the number of attributes of an XML element xml\_element as* *set by* **void raptor\_xml\_element\_set\_attributes***.*

- **int raptor\_xml\_element\_declare\_namespace(raptor\_xml\_element\*** *xml\_element***, raptor\_namespace\*** *nspace***)**

  *Declare an XML namespace nspace expliclitly on XML element* *xml\_element.  Namespaces used in the element or attribute* *names are automatically declared, this method allows additional ones* *to be done.*

- **int raptor\_xml\_element\_is\_empty(raptor\_xml\_element\*** *xml\_element***)**

  *Return non-0 if the XML element is empty.*

- **int raptor\_iostream\_write\_xml\_element(raptor\_iostream\*** *iostr***, raptor\_xml\_element \****element***, raptor\_namespace\_stack\*** *nstack***, int** *is\_empty***, int** *is\_end***, raptor\_simple\_message\_handler** *error\_handler***, void\*** *error\_data***, int** *depth***)**

  *Write a XML element xml\_element to iostream ostr.* *This is done in context of an XML namespace stack nstack and* *at depth depth in the stack (see Namespace class constructors).*

-

  *The element may be an empty element if is\_empty is non-zero or may* *be a close element if is\_end is non-zero (else is a start* *element).  The error\_handler method along* *with error\_data allow error reporting to be given.*

- **const unsigned char\* raptor\_xml\_element\_get\_language(raptor\_xml\_element\*** *xml\_element***)**

  *Get the xml:lang language of the XML element.*

## XML WRITER CLASS

*This class provides the functionality to generate simple XML documents* *consisting of elements with attributes, character data and* *comments. The documents can be written to an iostream.*

## XML WRITER CONSTRUCTOR

- **raptor\_xml\_writer\* raptor\_new\_xml\_writer(raptor\_namespace\_stack\*** *nstack***, raptor\_uri\_handler\*** *uri\_handler***, void\*** *uri\_context***, raptor\_iostream\*** *iostr***, raptor\_simple\_message\_handler** *error\_handler***, void \****error\_data***, int** *canonicalize***)**

  *Create a new XML Writer writing to iostream iostr.* *The error\_handler method along* *with error\_data allow error reporting to be given.* *nstack is either an existing namespace stack to be used or if* *NULL, a new one with only the XML namespace defined is created.* *Note that* **raptor\_uri\_get\_handler** *can be useful to return the* *current raptor URI handler/context.  canonicalize is currently* *unused and should be set to 1 but may allow non-canonical XML writing* *to be allowed in future.*

## XML WRITER DESTRUCTOR

- **void raptor\_free\_xml\_writer(raptor\_xml\_writer\*** *xml\_writer***)**

  *Destroy a XML Writer object.*

## XML WRITER METHODS

- **void raptor\_xml\_writer\_empty\_element(raptor\_xml\_writer\*** *xml\_writer***, raptor\_xml\_element \****element***)**

  *Write XML element element as an empty element (no element* *content) to the XML Writer xml\_writer.*

- **void raptor\_xml\_writer\_start\_element(raptor\_xml\_writer\*** *xml\_writer***, raptor\_xml\_element \****element***)**

  *Write a start element along with an attributes and namespace* *declarations for XML element element to the XML Writer* *xml\_writer.*

- **void raptor\_xml\_writer\_end\_element(raptor\_xml\_writer\*** *xml\_writer***, raptor\_xml\_element \****element***)**

  *Write an end element form for XML element element* *to the XML Writer xml\_writer.*

- **void raptor\_xml\_writer\_cdata(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char \*str)**

  *Write XML character data in str to the XML Writer* *xml\_writer.  The characters in str will be XML escaped.*

- **void raptor\_xml\_writer\_cdata\_counted(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char\*** *str***, unsigned int** *length***)**

  *Write XML character data in str of length length to the XML Writer* *xml\_writer.  The characters in str will be XML escaped.*

- **void raptor\_xml\_writer\_raw(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char\*** *str***)**

  *Write character data in str length to the XML Writer* *xml\_writer without XML escaping.*

- **void raptor\_xml\_writer\_raw\_counted(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char\*** *str***, unsigned int** *length***)**

  *Write character data in str of length length to the XML Writer* *xml\_writer without XML escaping.*

- **void raptor\_xml\_writer\_comment(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char\*** *str***)**

  *Write an XML comment in str to the XML Writer xml\_writer.*

- **void raptor\_xml\_writer\_comment\_counted(raptor\_xml\_writer\*** *xml\_writer***, const unsigned char\*** *str***, unsigned int** *length***)**

  *Write an XML comment in str of length length to the XML* *Writer xml\_writer.*

- **int raptor\_xml\_writer\_features\_enumerate(const raptor\_feature** *feature***, const char \*\****name***, raptor\_uri \*\****uri***, const char \*\****label***)**

  *Return the name, URI, string label (all optional)* *for an XML write feature, returning non-zero if no such feature exists.*

*Raptor features have URIs that are constructed from the URI* *http://feature.librdf.org/raptor- and the name* *so for example feature scanForRDF* *has URI http://feature.librdf.org/raptor-scanForRDF*

- **int raptor\_xml\_writer\_set\_feature(raptor\_xml\_writer\*** *xml\_writer***, raptor\_feature** *feature***, int** *value***)**

  *Set an XML writer feature feature to a particular value.* *Returns non 0 on failure or if the feature is unknown.* *The current defined writer features are:*\
     *Feature                                 Values*\
     **RAPTOR\_FEATURE\_WRITER\_AUTO\_INDENT**       *Boolean (non 0 true)*\
     **RAPTOR\_FEATURE\_WRITER\_AUTO\_EMPTY**        *Boolean (non 0 true)*\
     **RAPTOR\_FEATURE\_WRITER\_INDENT\_WIDTH**      *Integer*\
     **RAPTOR\_FEATURE\_WRITER\_XML\_DECLARATION**   *Boolean (non 0 true)*

*If the writer\_auto\_indent* *feature is set (default true), the XML writer will automatically* *indent the output.*

*If the writer\_auto\_empty* *feature is set (default true), the XML writer will automatically* *generate empty elements if a start/end element sequence has no content.*

*If the writer\_indent\_width* *feature is set (default 2) if the XML writer is outputing indented* *XML, it will use that many spaces.*

*If the writer\_xml\_declaration* *feature is set (default true) the XML declaration is written at the* *start of serialized XML.*

- **int raptor\_xml\_writer\_set\_feature\_string(raptor\_xml\_writer \*xml\_writer, raptor\_feature feature, const unsigned char \*value)**

  *Set an XML writer feature feature to a particular string value.* *Returns non 0 on failure or if the feature is unknown.* *The current defined XML writer features are given in* **raptor\_xml\_writer\_set\_feature** *and at present only take integer values. If* *an integer value feature is set with this function, value is* *interpreted as an integer and then that value is used.*

- **int raptor\_xml\_writer\_get\_feature(raptor\_xml\_writer\*** *xml\_writer***, raptor\_feature** *feature***)**

  *Get XML writer feature integer values.  The allowed feature values* *and types are given under* **raptor\_xml\_writer\_features\_enumerate***.*

- **const unsigned char \*raptor\_xml\_writer\_get\_feature\_string(raptor\_xml\_writer\*** *xml\_writer***, raptor\_feature** *feature***)**

  *Get XML writer feature string values. The allowed feature values* *and types are given under* **raptor\_xml\_writer\_features\_enumerate***.*

- **int raptor\_xml\_writer\_get\_depth(raptor\_xml\_writer\*** *xml\_writer***)**

  *Get the current XML writer element stack depth.*

- **void raptor\_xml\_writer\_flush(raptor\_xml\_writer\*** *xml\_writer***)**

  *Flush the XML writer output for any pending writes.*

- **void raptor\_xml\_writer\_newline(raptor\_xml\_writer\*** *xml\_writer***)**

  *Write a newline to the XML writer (which may trigger indenting before* *the next item).*

## WORLD CLASS

*This class stores the library state and configuration.  It will be* *the main class for initialsiing and configuring the library in Raptor* *2.0.*

## WORLD CLASS CONSTRUCTOR

- **raptor\_world\* raptor\_new\_world(void)**

  *Create a new raptor library object.*

## WORLD CLASS DESTRUCTOR

- **void raptor\_free\_world(raptor\_world\*** *world***)**

  *Destroy a raptor library object and free all resources.*

## WORLD CLASS METHODS

- **int raptor\_world\_open(raptor\_world\*** *world***)**

  *Start using a raptor library - allocate any dependent resources.* *This is optional.*

- **void raptor\_world\_set\_libxslt\_security\_preferences(raptor\_world \****world***, void \*security\_preferences)**

  *See* **raptor\_set\_libxslt\_security\_preferences()** *description.*

- **void raptor\_world\_set\_libxml\_flags(raptor\_world \****world***, int flags)**

  *See* **raptor\_set\_libxml\_flags()** *description.*

## API CHANGES

### 1.4.21

*No changes.*

### 1.4.20

*No changes.*

### 1.4.19

*Added* **raptor\_world** *class to prepare for V2 API with* *constructor* **raptor\_new\_world()***,* *destructor* **raptor\_free\_world()** *and methods* **raptor\_world\_open()***,* **raptor\_world\_set\_libxslt\_security\_preferences()** *and* **raptor\_world\_set\_libxml\_flags()***.*

*The* **raptor\_identifier***,* **raptor\_error\_handlers** *structs both* *gained a raptor\_world\* pointer field.*

*Added* **raptor\_set\_libxslt\_security\_preferences()** *and* **raptor\_set\_libxml\_flags()***.*

*Added* **raptor\_libxml\_flags** *enum for flags for*  **raptor\_world\_set\_libxml\_flags()** *and* **raptor\_set\_libxml\_flags()***.*

*Added* **RAPTOR\_FEATURE\_PREFIX\_ELEMENTS**

### 1.4.18

*Added atom serializer*

*Added rdfa parser*

*Added serializer features* **RAPTOR\_FEATURE\_RSS\_TRIPLES** *and* **RAPTOR\_FEATURE\_ATOM\_ENTRY\_URI**

*Added* **raptor\_qname\_to\_counted\_name()**

*Added* **raptor\_serialize\_start\_to\_iostream()**

*Added* **raptor\_sequence\_delete\_at()**

*Added* **raptor\_xml\_writer\_newline()**

*Added* **raptor\_xml\_writer\_flush()**

*Added* **raptor\_xml\_writer\_get\_depth()**

### 1.4.17

*Added SAX2 class* **raptor\_sax2***.* *Added new SAX2 API typedefs:* **raptor\_sax2\_start\_element\_handler***,* **raptor\_sax2\_end\_element\_handler***,* **raptor\_sax2\_characters\_handler***,* **raptor\_sax2\_cdata\_handler***,* **raptor\_sax2\_comment\_handler***,* **raptor\_sax2\_unparsed\_entity\_decl\_handler** *and* **raptor\_sax2\_external\_entity\_ref\_handler***.* *Added new SAX2 API functions:* **raptor\_new\_sax2()***,* **raptor\_free\_sax2()***,* **raptor\_sax2\_set\_start\_element\_handler()***,* **raptor\_sax2\_set\_end\_element\_handler()***,* **raptor\_sax2\_set\_characters\_handler()***,* **raptor\_sax2\_set\_cdata\_handler()***,* **raptor\_sax2\_set\_comment\_handler()***,* **raptor\_sax2\_set\_unparsed\_entity\_decl\_handler()***,* **raptor\_sax2\_set\_external\_entity\_ref\_handler()***,* **raptor\_sax2\_set\_namespace\_handler()***,* **raptor\_sax2\_parse\_start()***,* **raptor\_sax2\_parse\_chunk()***,* **raptor\_sax2\_inscope\_xml\_language()** *and* **raptor\_sax2\_inscope\_base\_uri()**

*Added features* **RAPTOR\_FEATURE\_WRITE\_BASE\_URI***,* **RAPTOR\_FEATURE\_WWW\_HTTP\_CACHE\_CONTROL***,* **RAPTOR\_FEATURE\_WWW\_HTTP\_USER\_AGENT***,* **RAPTOR\_FEATURE\_JSON\_CALLBACK** *and* **RAPTOR\_FEATURE\_JSON\_EXTRA\_DATA**

*Added* **raptor\_handler\_closure** *structure for error handlers.*

*Added* **raptor\_statement\_compare()**

*Added* **raptor\_iostream\_write\_string\_python()** *and deprecated* **raptor\_iostream\_write\_string\_turtle()**

**raptor\_uri\_set\_handler()***,* **raptor\_uri\_get\_handler()***,* **raptor\_new\_namespaces()***,* **raptor\_namespaces\_init()** *and* **raptor\_new\_xml\_writer()** *now take const handler pointers.*

*Added* **raptor\_www\_set\_http\_cache\_control()**

*Added QName class methods:* **raptor\_qname\_get\_local\_name()***,* **raptor\_qname\_get\_value()** *and* **raptor\_qname\_get\_counted\_value()**

*Added* **raptor\_iostream** *read handler typedefs*  **raptor\_iostream\_read\_bytes\_func***,* **raptor\_iostream\_read\_eof\_func** *and* *added new structure* **raptor\_iostream\_handler2** *replacing deprecated* **raptor\_iostream\_handler***.*

*Added* **raptor\_new\_iostream\_from\_handler2()** *replacing* *deprecated* **raptor\_new\_iostream\_from\_handler()**

*Added* **raptor\_new\_iostream\_from\_sink()***,* **raptor\_new\_iostream\_from\_filename()***,* **raptor\_new\_iostream\_from\_file\_handle()** *and* **raptor\_new\_iostream\_from\_string()***.*

*Added* **raptor\_iostream\_tell** *deprecating* **raptor\_iostream\_get\_bytes\_written\_count()***.*

*Added* **raptor\_iostream\_read\_bytes()** *and* **raptor\_iostream\_read\_eof()***.*

*Added* **raptor\_xml\_element\_get\_language()***.*

*Added new enum* **raptor\_log\_level***.*

*Added new typedef* **raptor\_error\_handlers***.* *and new function* **raptor\_error\_handlers\_init()***.*

### 1.4.16

**raptor\_namespaces\_init()** *now returns an integer status*

*Added* **raptor\_new\_xml\_element\_from\_namespace\_local\_name()**

*Added* **raptor\_uri\_compare()***.*

*Added new features for the 'grddl' parser:* **RAPTOR\_FEATURE\_HTML\_TAG\_SOUP***,* **RAPTOR\_FEATURE\_MICROFORMATS** *and* **RAPTOR\_FEATURE\_HTML\_LINK***.*

*Added parser feature* **RAPTOR\_FEATURE\_WWW\_TIMEOUT**

*Added raptor\_graph\_handler typedef and* **raptor\_set\_graph\_handler()**

*Added raptor\_www\_final\_uri\_handler typedef and* **raptor\_www\_set\_final\_uri\_handler()**

*Added* **raptor\_www\_set\_connection\_timeout()**

*Added* **raptor\_www\_get\_final\_uri()**

### 1.4.15

*No changes.*

### 1.4.14

*Add two new exported strings raptor\_license\_string and raptor\_home\_url\_string.*

*Added new features for the 'dot' serializer:* **RAPTOR\_FEATURE\_RESOURCE\_BORDER***,* **RAPTOR\_FEATURE\_LITERAL\_BORDER***,* **RAPTOR\_FEATURE\_BNODE\_BORDER***,* **RAPTOR\_FEATURE\_RESOURCE\_FILL***,* **RAPTOR\_FEATURE\_LITERAL\_FILL** *and* **RAPTOR\_FEATURE\_BNODE\_FILL**

*Added* **raptor\_parser\_generate\_id()**

*Added* **raptor\_iostream\_write\_string\_turtle()**

### 1.4.13

*No API changes.*

### 1.4.12

*No API changes.*

### 1.4.11

*Added* **raptor\_get\_feature\_count()**

*Added* **raptor\_get\_need\_base\_uri()**

*Added parser feature* **RAPTOR\_FEATURE\_NO\_NET**

*Added* **raptor\_www\_set\_uri\_filter()***,* **raptor\_parser\_set\_uri\_filter()** *with filter type* **raptor\_uri\_filter\_func**

### 1.4.10

*No API changes.*

### 1.4.9

*Added* **raptor\_parser\_get\_accept\_header()**

*Added* **raptor\_xml\_element\_is\_empty()**

*Added* **raptor\_qname\_get\_namespace()**

*Added* **raptor\_iostream\_write\_uri()**

*Added* **raptor\_namespaces\_qname\_from\_uri()***.*

*Added* **raptor\_namespace\_get\_counted\_prefix()**

*Added* **raptor\_serialize\_set\_namespace\_from\_namespace()**

*Deprecated* **raptor\_uri\_is\_file\_uri()** *for new* **raptor\_uri\_string\_is\_file\_uri()***.*

*Added* **raptor\_xml\_element\_get\_attributes()** *and* **raptor\_xml\_element\_get\_attributes\_count()**

### 1.4.8

*Added* **raptor\_set\_namespace\_handler()***.*

*Added XML 1.1 serializing support, feature* **RAPTOR\_FEATURE\_WRITER\_XML\_VERSION** *with shortname* *xmlVersion for serializer and xml writer classes to support* *it.  Added XML writer feature* **RAPTOR\_FEATURE\_WRITER\_XML\_DECLARATION** *to control generation* *of the XML declaration.* *Added new functions* **raptor\_xml\_any\_escape\_string()** *and* **raptor\_iostream\_write\_xml\_any\_escaped\_string()** *to allow* *generating XML 1.1 or XML 1.0.*

**RAPTOR\_IDENTIFIER\_TYPE\_PREDICATE** *will no longer be generated* *from version 1.4.9 onwards as the type of returned statement predicates.* **RAPTOR\_IDENTIFIER\_TYPE\_RESOURCE** *will be returned.*

**RAPTOR\_IDENTIFIER\_TYPE\_ORDINAL** *may no longer be generated* *from version 1.4.9 onwards,* **RAPTOR\_IDENTIFIER\_TYPE\_RESOURCE** *may replace it.*

### 1.4.7

*No changes.*

### 1.4.6

*No changes.*

### 1.4.5

*Deprecated* **raptor\_ntriples\_string\_as\_utf8\_string()** *(never* *documented above) since it can only work with a raptor\_parser object* *which makes it rather unusable alone.*

*Added XML writer features and support functions* **raptor\_xml\_writer\_features\_enumerate()***,* **raptor\_xml\_writer\_set\_feature()***,* **raptor\_xml\_writer\_set\_feature\_string()***,* **raptor\_xml\_writer\_get\_feature()** *and* **raptor\_xml\_writer\_get\_feature\_string()**

### 1.4.3

*Added XML Writer class (***raptor\_xml\_writer***)* *and XML Element class (***raptor\_xml\_element***)*

*Added* **raptor\_parser\_get\_feature\_string()***,* **raptor\_parser\_set\_feature\_string()***,* **raptor\_serializer\_set\_feature\_string()***,* **raptor\_serializer\_get\_feature\_string()** *and* **raptor\_feature\_value\_type()***.*

*Added* **raptor\_serializer\_set\_namespace***,* **raptor\_serializer\_set\_feature()** *and* **raptor\_serializer\_get\_feature()***.*

*Added* **raptor\_new\_namespace\_from\_uri()***,* **raptor\_new\_namespace\_parts\_from\_string()***,* *Added* **raptor\_namespaces\_find\_namespace\_by\_uri()***.* *and* **raptor\_iostream\_write\_namespace()** *to write a namespace* *declaration to an iostream.*

*Added copy constructor* **raptor\_qname\_copy()** *and* **raptor\_iostream\_write\_qname()** *to write a qname to an iostream.*

*Added* **raptor\_sequence\_join()** *to join two sequences, leaving one empty.*

*Added* **raptor\_iostream\_write\_stringbuffer()** *to write a* *stringbuffer to an iostream.*

*Added N-Triples* **raptor\_iostream\_write\_string\_ntriples()** *and* **raptor\_iostream\_write\_statement\_ntriples()** *utility functions for writing to raptor\_iostreams.*

*Added* **raptor\_uri\_to\_relative\_counted\_uri\_string()***,* **raptor\_uri\_to\_relative\_uri\_string()***.* **raptor\_uri\_print()***,* **raptor\_uri\_to\_counted\_string()** *and* **raptor\_uri\_to\_string()**

*Added unicode name checking utility functions for XML 1.0 and XML 1.1* *name starting character and continued name character.* **raptor\_unicode\_is\_xml10\_namestartchar** **raptor\_unicode\_is\_xml10\_namechar***,* **raptor\_unicode\_is\_xml11\_namechar** *and* **raptor\_unicode\_is\_xml11\_namestartchar***.*

*Added* **raptor\_xml\_name\_check** *to check if a name is a legal XML 1.0 or 1.0 name.* *and* **raptor\_iostream\_write\_xml\_escaped\_string** *to write* *an XML-escaped string to an iostream.*

*Added UTF8-checking utility function* **raptor\_utf8\_check***.*

### 1.4.2

*No changes.*

### 1.4.1

*The* **raptor\_xml\_escape\_string** *now returns \<0 on failure rather* *than 0, so that if an empty string is escaped, 0 bytes required is* *returned.*

### 1.4.0

*Added new* **raptor\_serializer** *class supporting RDF/XML (name* **rdfxml***) and N-Triples (name* **ntriples***).*\
 *Added new* **raptor\_iostream** *class*\
 *Added* **raptor\_stringbuffer\_copy\_to\_string** *to allow efficient* *copy-out of a constructed string.*\
 *Added* **raptor\_www\_fetch\_to\_string** *to allow retrieving of* *web content as a single string.*

### 1.3.3

*Added* **raptor\_calloc\_memory** *to provide a calloc inside raptor.*\
 *Added feature check\_rdf\_id (see raptor\_set\_feature documentation).*

### 1.3.2

*Added* **raptor\_alloc\_memory** *to allocate memory inside raptor.*

*Added accessor functions for the public raptor\_locator structure:*

**raptor\_locator\_line**\
 **raptor\_locator\_column**\
 **raptor\_locator\_byte**\
 **raptor\_locator\_file**\
 **raptor\_locator\_uri**

### 1.3.1

*Correct raptor\_print\_statement declaration argument statement to have* *one less 'const', to match the code.*

### 1.3.0

*Added the following parser methods, utility methods and helper functions:*

**raptor\_new\_parser\_for\_content (Parser class constructor)**\
 **raptor\_get\_mime\_type**\
 **raptor\_get\_feature**\
 **raptor\_syntax\_name\_check**\
 **raptor\_guess\_parser\_name**\
 **raptor\_features\_enumerate**\
 **raptor\_feature\_from\_uri**\
 **raptor\_www\_set\_http\_accept (WWW class)**

*Changed* **raptor\_set\_feature** *to now return an int success or failure.*

*Added the following functions:*\
 **raptor\_free\_memory**\
 **raptor\_unicode\_char\_to\_utf8**\
 **raptor\_utf8\_to\_unicode\_char**\
 **raptor\_vsnprintf**

*Added the raptor\_sequence class, its constructor, destructor, methods* *and helper functions.*

*Added the raptor\_stringbuffer class and constructor, destructor and methods.*

*Deprecated* **raptor\_print\_statement\_detailed** *always intended to* *be internal.*

### 1.2.0

*Added* **raptor\_syntaxes\_enumerate** *to get full information* *on syntax mime type and URIs as well as name and label.*

*N-Triples Plus parser renamed to Turtle (name turtle)*

### 1.1.0

*Added N-Triples Plus parser (name ntriples-plus)*

*Made URI class constructors, methods and factory methods as* *well as some other utility functions using or returning URIs or* *literals take unsigned char\* rather than char\*.  The affected calls are:*

*URI factory methods changed to all take/return unsigned char\* for URI* *strings:*\
 **raptor\_new\_uri\_func**\
 **raptor\_new\_uri\_from\_local\_name\_func**\
 **raptor\_new\_uri\_relative\_to\_base\_func**\
 **raptor\_uri\_as\_string\_func**\
 **raptor\_uri\_as\_counted\_string\_func**

*Constructors and methods changed to take/return unsigned char\* for* *URI strings:*\
 **raptor\_statement\_part\_as\_counted\_string**\
 **raptor\_statement\_part\_as\_string**\
 **raptor\_new\_uri**\
 **raptor\_new\_uri\_from\_uri\_local\_name**\
 **raptor\_new\_uri\_relative\_to\_base**\
 **raptor\_uri\_as\_string**\
 **raptor\_uri\_as\_counted\_string**\
 **raptor\_print\_ntriples\_string**

*Changed to use unsigned char\* for URI strings, char\* for filenames:*\
 **raptor\_uri\_resolve\_uri\_reference**\
 **raptor\_uri\_filename\_to\_uri\_string**\
 **raptor\_uri\_uri\_string\_to\_filename**\
 **raptor\_uri\_uri\_string\_to\_filename\_fragment**\
 **raptor\_uri\_is\_file\_uri**

*Changed to return unsigned char\* for UTF8 string:*\
 **raptor\_ntriples\_string\_as\_utf8\_string**

*Added* **raptor\_parsers\_enumerate** *to discover supported parsers.*

*Added* **raptor\_uri\_uri\_string\_to\_filename\_fragment** *with fragment arg to* *return the URI fragment.*

*Made the raptor\_namespace, raptor\_namespace\_stack and raptor\_qname* *class and APIs public.*

*Added feature non\_nfc\_fatal (see raptor\_set\_feature documentation).*

### 1.0.0

*Removed the following deprecated methods and functions (see 0.9.6* *changes for the new names):*\
 **raptor\_free***,* **raptor\_new***,* **raptor\_ntriples\_free***,* **raptor\_ntriples\_new***,* **raptor\_ntriples\_parse\_file***,* **raptor\_ntriples\_set\_error\_handler***,* **raptor\_ntriples\_set\_fatal\_error\_handler***,* **raptor\_ntriples\_set\_statement\_handler** *and* **raptor\_parser\_abort***.*

*Added* **raptor\_parse\_file\_stream** *for reading FILE\* streams without necessarily having a file.*

### 0.9.12

*Added* **raptor\_new\_uri\_for\_retrieval** *to turn URI references into URIs suitable for retrieval (no fragments).*

### 0.9.11

*Added* **raptor\_get\_name** *and* **raptor\_get\_label***.*

**raptor\_xml\_escape\_string** *now takes error message handler, data* *pointer, loses parser argument.*

*Added* **raptor\_set\_default\_generate\_id\_parameters** *and* **raptor\_set\_generate\_id\_handler** *to control the default* *generation of IDs, allow full customisation.*

### 0.9.10

*Added* **raptor\_set\_parser\_strict** *and* **raptor\_www\_no\_www\_library\_init\_finish***.*

**raptor\_xml\_escape\_string** *now takes an output string length pointer.*

*Added* **raptor\_statement\_part\_as\_counted\_string***,* **raptor\_statement\_part\_as\_string and raptor\_parse\_abort.**

**Deprecated raptor\_parser\_abort.**

### 0.9.9

**Added raptor\_www class and all its constructors, destructor, methods, calls.**

**Added raptor\_parse\_uri, raptor\_parser\_abort, raptor\_ntriples\_term\_as\_string and raptor\_xml\_escape\_string.**

### 0.9.7

**raptor\_parse\_chunk, raptor\_new\_uri\_from\_id, arguments are now unsigned char.**

**Added raptor\_new\_uri\_for\_xmlbase.**

### 0.9.6

**In this version, the raptor/ntriples parser calling APIs were** **modified.  The following table lists the changes:**

*OLD API	NEW API (0.9.6+)*\
 **raptor\_new()	raptor\_new\_parser("rdfxml")**\
 **ntriples\_new()	raptor\_new\_parser("ntriples")**\
 **raptor\_free	raptor\_free\_parser**\
 **ntriples\_free	raptor\_ntriples\_parser**\
 **raptor\_ntriples\_parse\_file	raptor\_parse\_file**\
 **raptor\_ntriples\_set\_error\_handler	raptor\_set\_error\_handler**\
 **raptor\_ntriples\_set\_fatal\_error\_handler	raptor\_set\_fatal\_error\_handler**\
 **raptor\_ntriples\_set\_statement\_handler	raptor\_set\_statement\_handler**\

## CONFORMING TO

*RDF/XML Syntax (Revised)***, Dave Beckett (ed.)** **W3C Recommendation,** **http://www.w3.org/TR/rdf-syntax-grammar/** ⟨http://www.w3.org/TR/rdf-syntax-grammar/⟩

*N-Triples***, in** *RDF Test Cases***, Jan Grant and Dave Beckett (eds.)** **W3C Recommendation,** **http://www.w3.org/TR/rdf-testcases/#ntriples** ⟨http://www.w3.org/TR/rdf-testcases/#ntriples⟩

*Turtle - Terse RDF Triple Language***, Dave Beckett,** **http://www.dajobe.org/2004/01/turtle/** ⟨http://www.dajobe.org/2004/01/turtle/⟩

*RSS 0.91 spec revision 3***, Dan Libby, Netscape,** **http://my.netscape.com/publish/formats/rss-spec-0.91.html** ⟨http://my.netscape.com/publish/formats/rss-spec-0.91.html⟩

*RDF Site Summary (RSS) 1.0***,** **http://purl.org/rss/1.0/spec** ⟨http://purl.org/rss/1.0/spec⟩

*Atom 1.0 syndication format***,** **RFC 4287,** **http://www.ietf.org/rfc/rfc4287.txt** ⟨http://www.ietf.org/rfc/rfc4287.txt⟩

*Gleaning Resource Descriptions from Dialects of Languages* *(GRDDL)***, Dan Connolly (ed.), W3C Recommendation, 2007-09-11,** **http://www.w3.org/TR/2007/REC-grddl-20070911/** ⟨http://www.w3.org/TR/2007/REC-grddl-20070911/⟩

*RDFa in XHTML: Syntax and Processing***,** **Ben Adida, Mark Birbeck, Shane McCarron, Steven Pemberton (eds.)**\
  **W3C Recommendation, 2008-10-14,** **http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014/** ⟨http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014/⟩

## SEE ALSO

**[rapper(1)](/rapper/1.md),**[raptor-config(1)](/raptor-config/1.md)

## AUTHOR

**Dave Beckett -**  **http://www.dajobe.org/** ⟨http://www.dajobe.org/⟩
