![]() |
![]() |
![]() |
Raptor RDF Syntax Library Manual | ![]() |
---|---|---|---|---|
Top | Description |
typedef raptor_namespace; raptor_namespace * raptor_new_namespace_from_uri (raptor_namespace_stack *nstack
,const unsigned char *prefix
,raptor_uri *ns_uri
,int depth
); raptor_namespace_stack * raptor_new_namespaces (raptor_world *world
,int defaults
); int raptor_namespaces_init (raptor_world *world
,raptor_namespace_stack *nstack
,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
,const unsigned char *prefix
,const 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
,const 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
,const unsigned char *prefix
,const unsigned char *ns_uri_string
,int depth
); void raptor_free_namespace (raptor_namespace *ns
); 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
); int raptor_namespace_write (raptor_namespace *ns
,raptor_iostream *iostr
); typedef raptor_namespace_stack; int raptor_namespace_stack_start_namespace (raptor_namespace_stack *nstack
,raptor_namespace *ns
,int new_depth
); unsigned char * raptor_namespace_format_as_xml (const raptor_namespace *ns
,size_t *length_p
); int raptor_xml_namespace_string_parse (const unsigned char *string
,unsigned char **prefix
,unsigned char **uri_string
);
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
,const unsigned char *prefix
,raptor_uri *ns_uri
,int depth
);
Constructor - create a new namespace from a prefix and URI object.
This declares but does not enable the namespace declaration (or 'start' it)
Use raptor_namespaces_start_namespace()
to make the namespace
enabled and in scope for binding prefixes.
Alternatively use raptor_namespaces_start_namespace_full()
can construct
and enable a namespace in one call.
|
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 (raptor_world *world
,int defaults
);
Constructor - create a new raptor_namespace_stack.
See raptor_namespaces_init()
for the values of defaults
.
|
raptor_world object |
|
namespaces to initialise |
Returns : |
a new namespace stack or NULL on failure |
int raptor_namespaces_init (raptor_world *world
,raptor_namespace_stack *nstack
,int defaults
);
Initialise an existing namespaces stack object
This sets up the stack optionally with some common RDF namespaces.
defaults
can be 0 for none, 1 for just XML, 2 for RDF, RDFS, OWL
and XSD (RDQL uses this) or 3+ undefined.
|
raptor_world object |
|
raptor_namespace_stack to initialise |
|
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
,const unsigned char *prefix
,const unsigned char *ns_uri_string
,int depth
);
Create a new namespace and start it on a stack of namespaces.
See raptor_new_namespace()
for the meanings of prefix
,
ns_uri_string
and depth
for namespaces.
|
namespace stack |
|
new namespace prefix (or NULL) |
|
new namespace URI (or NULL) |
|
new namespace depth |
Returns : |
non-0 on failure |
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
,const 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
,const unsigned char *prefix
,const unsigned char *ns_uri_string
,int depth
);
Constructor - create a new namespace from a prefix and URI string with a depth scope.
This declares but does not enable the namespace declaration (or 'start' it)
Use raptor_namespaces_start_namespace()
to make the namespace
enabled and in scope for binding prefixes.
Alternatively use raptor_namespaces_start_namespace_full()
can construct
and enable a namespace in one call.
The depth
is a way to use the stack of namespaces for providing scoped
namespaces where inner scope namespaces override outer scope namespaces.
This is primarily for RDF/XML and XML syntaxes that have hierarchical
elements. The main use of this is raptor_namespaces_end_for_depth()
to disable ('end') all namespaces at a given depth. Otherwise set this
to 0.
|
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 |
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 |
int raptor_namespace_write (raptor_namespace *ns
,raptor_iostream *iostr
);
Write a formatted namespace to an iostream
|
namespace to write |
|
raptor iosteram |
Returns : |
non-0 on failure |
raptor_namespace_stack* raptor_namespace_stack;
Raptor XML Namespace Stack class
int raptor_namespace_stack_start_namespace (raptor_namespace_stack *nstack
,raptor_namespace *ns
,int new_depth
);
Copy an existing namespace to a namespace stack with a new depth and start it.
The depth
is a way to use the stack of namespaces for providing scoped
namespaces where inner scope namespaces override outer scope namespaces.
This is primarily for RDF/XML and XML syntaxes that have hierarchical
elements. The main use of this is raptor_namespaces_end_for_depth()
to disable ('end') all namespaces at a given depth. If depths are
not being needed it is unlikely this call is ever needed to copy an
existing namespace at a new depth.
|
namespace stack |
|
namespace |
|
new depth |
Returns : |
non-0 on failure |
unsigned char * raptor_namespace_format_as_xml (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_xml_namespace_string_parse()
|
namespace object |
|
pointer to length (or NULL) |
Returns : |
namespace formatted as newly allocated string or NULL on failure |
int raptor_xml_namespace_string_parse (const unsigned char *string
,unsigned char **prefix
,unsigned char **uri_string
);
Parse a string containing an XML style namespace declaration into a namespace prefix and URI pair.
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
. Either but not both may be NULL.
See also raptor_namespace_format_as_xml()
|
string to parse |
|
pointer to location to store namespace prefix |
|
pointer to location to store namespace URI |
Returns : |
non-0 on failure. |