|  |  |  | Raptor RDF Syntax Parsing and Serializing Library Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
typedef raptor_namespace; raptor_namespace* raptor_new_namespace_from_uri (raptor_namespace_stack *nstack, unsigned char *prefix, raptor_uri *ns_uri, int depth); raptor_namespace_stack* raptor_new_namespaces (const 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, const raptor_uri_handler *uri_handler, void *uri_context, raptor_simple_message_handler error_handler, void *error_data, int defaults); void raptor_namespaces_clear (raptor_namespace_stack *nstack); void raptor_free_namespaces (raptor_namespace_stack *nstack); void raptor_namespaces_start_namespace (raptor_namespace_stack *nstack, raptor_namespace *nspace); int raptor_namespaces_start_namespace_full (raptor_namespace_stack *nstack, unsigned char *prefix, unsigned char *ns_uri_string, int depth); void raptor_namespaces_end_for_depth (raptor_namespace_stack *nstack, int depth); raptor_namespace* raptor_namespaces_get_default_namespace (raptor_namespace_stack *nstack); raptor_namespace * raptor_namespaces_find_namespace (raptor_namespace_stack *nstack, unsigned char *prefix, int prefix_length); raptor_namespace* raptor_namespaces_find_namespace_by_uri (raptor_namespace_stack *nstack, raptor_uri *ns_uri); int raptor_namespaces_namespace_in_scope (raptor_namespace_stack *nstack, const raptor_namespace *nspace); raptor_namespace* raptor_new_namespace (raptor_namespace_stack *nstack, unsigned char *prefix, unsigned char *ns_uri_string, int depth); void raptor_free_namespace (raptor_namespace *ns); int raptor_namespace_copy (raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth); raptor_uri* raptor_namespace_get_uri (const raptor_namespace *ns); const unsigned char* raptor_namespace_get_prefix (const raptor_namespace *ns); const unsigned char* raptor_namespace_get_counted_prefix (const raptor_namespace *ns, size_t *length_p); unsigned char * raptor_namespaces_format (const raptor_namespace *ns, size_t *length_p); int raptor_iostream_write_namespace (raptor_iostream *iostr, raptor_namespace *ns); int raptor_new_namespace_parts_from_string (unsigned char *string, unsigned char **prefix, unsigned char **uri_string); typedef raptor_namespace_stack; raptor_qname* raptor_namespaces_qname_from_uri (raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version);
Two classes that provide an XML namespace - short prefix (or none) and
absolute URI (or none) to match the form xmlns...="..."
seen in XML.  A stack of namespaces raptor_namespace_stack is also
provided to handle in-scope namespace calculations that happen inside
XML documents where inner namespaces can override outer ones.
raptor_namespace* raptor_new_namespace_from_uri (raptor_namespace_stack *nstack, unsigned char *prefix, raptor_uri *ns_uri, int depth);
Constructor - create a new namespace from a prefix and URI object.
| 
 | namespace stack | 
| 
 | namespace prefix string | 
| 
 | namespace URI | 
| 
 | depth of namespace in the stack | 
| Returns : | a new raptor_namespace or NULL on failure | 
raptor_namespace_stack* raptor_new_namespaces (const raptor_uri_handler *uri_handler, void *uri_context, raptor_simple_message_handler error_handler, void *error_data, int defaults);
Constructor - create a new raptor_namespace_stack.
See raptor_namespaces_init() for the values of defaults.
uri_handler and uri_context parameters are ignored but are retained
in the API for backwards compatibility. Internally the same uri handler
as returned by raptor_uri_get_handler() will be used.
raptor_init() MUST have been called before calling this function.
Use raptor_new_namespaces_v2() if using raptor_world APIs.
| 
 | URI handler function (ignored) | 
| 
 | URI handler context data (ignored) | 
| 
 | error handler function | 
| 
 | error handler data | 
| 
 | namespaces to initialise | 
| Returns : | a new namespace stack or NULL on failure | 
int raptor_namespaces_init (raptor_namespace_stack *nstack, const raptor_uri_handler *uri_handler, void *uri_context, raptor_simple_message_handler error_handler, void *error_data, int defaults);
Initialise a namespaces stack some optional common namespaces.
defaults can be 0 for none, 1 for just XML, 2 for RDF, RDFS, OWL
and XSD (RDQL uses this) or 3+ undefined.
uri_handler and uri_context parameters are ignored but are retained
in the API for backwards compatibility. Internally the same uri handler
as returned by raptor_uri_get_handler() will be used.
raptor_init() MUST have been called before calling this function.
Use raptor_namespaces_init_v2() if using raptor_world APIs.
| 
 | raptor_namespace_stack to initialise | 
| 
 | URI handler function (ignored) | 
| 
 | context for URI handler (ignored) | 
| 
 | error handler function | 
| 
 | context for error handler | 
| 
 | namespaces to initialise. | 
| Returns : | non-0 on error | 
void raptor_namespaces_clear (raptor_namespace_stack *nstack);
Empty a namespace stack of namespaces and any other resources.
| 
 | namespace stack | 
void raptor_free_namespaces (raptor_namespace_stack *nstack);
Destructor - destroy a namespace stack
| 
 | namespace stack | 
void raptor_namespaces_start_namespace (raptor_namespace_stack *nstack, raptor_namespace *nspace);
Start a namespace on a stack of namespaces.
| 
 | namespace stack | 
| 
 | namespace to start | 
int raptor_namespaces_start_namespace_full (raptor_namespace_stack *nstack, unsigned char *prefix, unsigned char *ns_uri_string, int depth);
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| Returns : | 
void raptor_namespaces_end_for_depth (raptor_namespace_stack *nstack, int depth);
End all namespaces at the given depth in the namespace stack.
| 
 | namespace stack | 
| 
 | depth | 
raptor_namespace* raptor_namespaces_get_default_namespace (raptor_namespace_stack *nstack);
Get the current default namespace in-scope in a stack.
| 
 | namespace stack | 
| Returns : | raptor_namespace or NULL if no default namespace is in scope | 
raptor_namespace * raptor_namespaces_find_namespace (raptor_namespace_stack *nstack, unsigned char *prefix, int prefix_length);
Find a namespace in a namespace stack by prefix.
Note that this uses the length so that the prefix may be a prefix (sic)
of a longer string.  If prefix is NULL, the default namespace will
be returned if present, prefix_length length is ignored in this case.
| 
 | namespace stack | 
| 
 | namespace prefix to find | 
| 
 | length of prefix. | 
| Returns : | raptor_namespace for the prefix or NULL on failure | 
raptor_namespace* raptor_namespaces_find_namespace_by_uri (raptor_namespace_stack *nstack, raptor_uri *ns_uri);
Find a namespace in a namespace stack by namespace URI.
| 
 | namespace stack | 
| 
 | namespace URI to find | 
| Returns : | raptor_namespace for the URI or NULL on failure | 
int raptor_namespaces_namespace_in_scope (raptor_namespace_stack *nstack, const raptor_namespace *nspace);
Test if a given namespace is in-scope in the namespace stack.
| 
 | namespace stack | 
| 
 | namespace | 
| Returns : | non-0 if the namespace is in scope. | 
raptor_namespace* raptor_new_namespace (raptor_namespace_stack *nstack, unsigned char *prefix, unsigned char *ns_uri_string, int depth);
Constructor - create a new namespace from a prefix and URI string.
| 
 | namespace stack | 
| 
 | namespace prefix string | 
| 
 | namespace URI string | 
| 
 | depth of namespace in the stack | 
| Returns : | a new raptor_namespace or NULL on failure | 
void raptor_free_namespace (raptor_namespace *ns);
Destructor - destroy a namespace.
| 
 | namespace object | 
int raptor_namespace_copy (raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth);
Copy a namespace to a new namespace stack with a new depth.
| 
 | namespace stack | 
| 
 | namespace | 
| 
 | new depth | 
| Returns : | non-0 on failure | 
raptor_uri* raptor_namespace_get_uri (const raptor_namespace *ns);
Get the namespace URI.
| 
 | namespace object | 
| Returns : | namespace URI or NULL | 
const unsigned char* raptor_namespace_get_prefix (const raptor_namespace *ns);
Get the namespace prefix.
| 
 | namespace object | 
| Returns : | prefix string or NULL | 
const unsigned char* raptor_namespace_get_counted_prefix (const raptor_namespace *ns, size_t *length_p);
Get the namespace prefix and length.
| 
 | namespace object | 
| 
 | pointer to store length or NULL | 
| Returns : | prefix string or NULL | 
unsigned char * raptor_namespaces_format (const raptor_namespace *ns, size_t *length_p);
Format a namespace in an XML style into a newly allocated string.
Generates a string of the form xmlns:prefix="uri", xmlns="uri", xmlns:prefix="" or xmlns="" depending on the namespace's prefix or URI. Double quotes are always used.
If length_p is not NULL, the length of the string is
stored in the address it points to.
See also raptor_new_namespace_parts_from_string()
| 
 | namespace object | 
| 
 | pointer to length (or NULL) | 
| Returns : | namespace formatted as newly allocated string or NULL on failure | 
int raptor_iostream_write_namespace (raptor_iostream *iostr, raptor_namespace *ns);
Write a formatted namespace to an iostream
| 
 | raptor iosteram | 
| 
 | namespace to write | 
| Returns : | non-0 on failure | 
int raptor_new_namespace_parts_from_string (unsigned char *string, unsigned char **prefix, unsigned char **uri_string);
Parse a string containin an XML style namespace declaration into a namespace prefix and URI.
The string is of the form xmlns:prefix="uri", xmlns="uri", xmlns:prefix="" or xmlns="". The quotes can be single or double quotes.
Two values are returned from this function into *prefix and
*uri_string neither of which may be NULL.
See also raptor_namespaces_format()
| 
 | string to parse | 
| 
 | pointer to location to store namespace prefix | 
| 
 | pointer to location to store namespace URI | 
| Returns : | non-0 on failure. | 
raptor_namespace_stack* raptor_namespace_stack;
Raptor XML Namespace Stack class
raptor_qname* raptor_namespaces_qname_from_uri (raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version);
Make an appropriate XML Qname from the namespaces on a namespace stack
Makes a qname from the in-scope namespaces in a stack if the URI matches the prefix and the rest is a legal XML name.
| 
 | namespace stack | 
| 
 | URI to use to make qname | 
| 
 | XML Version | 
| Returns : | raptor_qname for the URI or NULL on failure |