<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="raptor-section-xml-namespace">
<refmeta>
<refentrytitle role="top_of_page" id="raptor-section-xml-namespace.top_of_page">XML Namespaces</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>RAPTOR Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>XML Namespaces</refname>
<refpurpose>Namespaces in XML include stacks of Namespaces</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="raptor-section-xml-namespace.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
typedef             <link linkend="raptor-namespace">raptor_namespace</link>;
<link linkend="raptor-namespace">raptor_namespace</link>*   <link linkend="raptor-new-namespace-from-uri">raptor_new_namespace_from_uri</link>       (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         <link linkend="raptor-uri">raptor_uri</link> *ns_uri,
                                                         <link linkend="int">int</link> depth);
<link linkend="raptor-namespace-stack">raptor_namespace_stack</link>* <link linkend="raptor-new-namespaces">raptor_new_namespaces</link>           (const <link linkend="raptor-uri-handler">raptor_uri_handler</link> *uri_handler,
                                                         <link linkend="void">void</link> *uri_context,
                                                         <link linkend="raptor-simple-message-handler">raptor_simple_message_handler</link> error_handler,
                                                         <link linkend="void">void</link> *error_data,
                                                         <link linkend="int">int</link> defaults);
<link linkend="int">int</link>                 <link linkend="raptor-namespaces-init">raptor_namespaces_init</link>              (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         const <link linkend="raptor-uri-handler">raptor_uri_handler</link> *uri_handler,
                                                         <link linkend="void">void</link> *uri_context,
                                                         <link linkend="raptor-simple-message-handler">raptor_simple_message_handler</link> error_handler,
                                                         <link linkend="void">void</link> *error_data,
                                                         <link linkend="int">int</link> defaults);
<link linkend="void">void</link>                <link linkend="raptor-namespaces-clear">raptor_namespaces_clear</link>             (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);
<link linkend="void">void</link>                <link linkend="raptor-free-namespaces">raptor_free_namespaces</link>              (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);
<link linkend="void">void</link>                <link linkend="raptor-namespaces-start-namespace">raptor_namespaces_start_namespace</link>   (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *nspace);
<link linkend="int">int</link>                 <link linkend="raptor-namespaces-start-namespace-full">raptor_namespaces_start_namespace_full</link>
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         unsigned <link linkend="char">char</link> *ns_uri_string,
                                                         <link linkend="int">int</link> depth);
<link linkend="void">void</link>                <link linkend="raptor-namespaces-end-for-depth">raptor_namespaces_end_for_depth</link>     (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="int">int</link> depth);
<link linkend="raptor-namespace">raptor_namespace</link>*   <link linkend="raptor-namespaces-get-default-namespace">raptor_namespaces_get_default_namespace</link>
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);
<link linkend="raptor-namespace">raptor_namespace</link>*   <link linkend="raptor-namespaces-find-namespace">raptor_namespaces_find_namespace</link>    (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         <link linkend="int">int</link> prefix_length);
<link linkend="raptor-namespace">raptor_namespace</link>*   <link linkend="raptor-namespaces-find-namespace-by-uri">raptor_namespaces_find_namespace_by_uri</link>
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-uri">raptor_uri</link> *ns_uri);
<link linkend="int">int</link>                 <link linkend="raptor-namespaces-namespace-in-scope">raptor_namespaces_namespace_in_scope</link>
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         const <link linkend="raptor-namespace">raptor_namespace</link> *nspace);
<link linkend="raptor-namespace">raptor_namespace</link>*   <link linkend="raptor-new-namespace">raptor_new_namespace</link>                (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         unsigned <link linkend="char">char</link> *ns_uri_string,
                                                         <link linkend="int">int</link> depth);
<link linkend="void">void</link>                <link linkend="raptor-free-namespace">raptor_free_namespace</link>               (<link linkend="raptor-namespace">raptor_namespace</link> *ns);
<link linkend="int">int</link>                 <link linkend="raptor-namespace-copy">raptor_namespace_copy</link>               (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="int">int</link> new_depth);
<link linkend="raptor-uri">raptor_uri</link>*         <link linkend="raptor-namespace-get-uri">raptor_namespace_get_uri</link>            (const <link linkend="raptor-namespace">raptor_namespace</link> *ns);
const unsigned <link linkend="char">char</link>* <link linkend="raptor-namespace-get-prefix">raptor_namespace_get_prefix</link>        (const <link linkend="raptor-namespace">raptor_namespace</link> *ns);
const unsigned <link linkend="char">char</link>* <link linkend="raptor-namespace-get-counted-prefix">raptor_namespace_get_counted_prefix</link>
                                                        (const <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="size-t">size_t</link> *length_p);
unsigned <link linkend="char">char</link>*      <link linkend="raptor-namespaces-format">raptor_namespaces_format</link>            (const <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="size-t">size_t</link> *length_p);
<link linkend="int">int</link>                 <link linkend="raptor-iostream-write-namespace">raptor_iostream_write_namespace</link>     (<link linkend="raptor-iostream">raptor_iostream</link> *iostr,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *ns);
<link linkend="int">int</link>                 <link linkend="raptor-new-namespace-parts-from-string">raptor_new_namespace_parts_from_string</link>
                                                        (unsigned <link linkend="char">char</link> *string,
                                                         unsigned <link linkend="char">char</link> **prefix,
                                                         unsigned <link linkend="char">char</link> **uri_string);
typedef             <link linkend="raptor-namespace-stack">raptor_namespace_stack</link>;
<link linkend="raptor-qname">raptor_qname</link>*       <link linkend="raptor-namespaces-qname-from-uri">raptor_namespaces_qname_from_uri</link>    (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-uri">raptor_uri</link> *uri,
                                                         <link linkend="int">int</link> xml_version);
</synopsis>
</refsynopsisdiv>









<refsect1 id="raptor-section-xml-namespace.description" role="desc">
<title role="desc.title">Description</title>
<para>
Two classes that provide an XML namespace - short prefix (or none) and
absolute URI (or none) to match the form <literal>xmlns...="..."</literal>
seen in XML.  A stack of namespaces <link linkend="raptor-namespace-stack"><type>raptor_namespace_stack</type></link> is also
provided to handle in-scope namespace calculations that happen inside
XML documents where inner namespaces can override outer ones.
</para>
</refsect1>

<refsect1 id="raptor-section-xml-namespace.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="raptor-namespace" role="typedef">
<title>raptor_namespace</title>
<indexterm zone="raptor-namespace"><primary>raptor_namespace</primary></indexterm><programlisting>raptor_namespace* raptor_namespace;
</programlisting>
<para>
Raptor XML Namespace class</para>
<para>

</para></refsect2>
<refsect2 id="raptor-new-namespace-from-uri" role="function">
<title>raptor_new_namespace_from_uri ()</title>
<indexterm zone="raptor-new-namespace-from-uri"><primary>raptor_new_namespace_from_uri</primary></indexterm><programlisting><link linkend="raptor-namespace">raptor_namespace</link>*   raptor_new_namespace_from_uri       (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         <link linkend="raptor-uri">raptor_uri</link> *ns_uri,
                                                         <link linkend="int">int</link> depth);</programlisting>
<para>
Constructor - create a new namespace from a prefix and URI object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix</parameter>&nbsp;:</term>
<listitem><simpara> namespace prefix string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns_uri</parameter>&nbsp;:</term>
<listitem><simpara> namespace URI
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>depth</parameter>&nbsp;:</term>
<listitem><simpara> depth of namespace in the stack
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="raptor-namespace"><type>raptor_namespace</type></link> or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-new-namespaces" role="function">
<title>raptor_new_namespaces ()</title>
<indexterm zone="raptor-new-namespaces"><primary>raptor_new_namespaces</primary></indexterm><programlisting><link linkend="raptor-namespace-stack">raptor_namespace_stack</link>* raptor_new_namespaces           (const <link linkend="raptor-uri-handler">raptor_uri_handler</link> *uri_handler,
                                                         <link linkend="void">void</link> *uri_context,
                                                         <link linkend="raptor-simple-message-handler">raptor_simple_message_handler</link> error_handler,
                                                         <link linkend="void">void</link> *error_data,
                                                         <link linkend="int">int</link> defaults);</programlisting>
<para>
Constructor - create a new <link linkend="raptor-namespace-stack"><type>raptor_namespace_stack</type></link>.
</para>
<para>
See <link linkend="raptor-namespaces-init"><function>raptor_namespaces_init()</function></link> fo the values of <parameter>defaults</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>uri_handler</parameter>&nbsp;:</term>
<listitem><simpara> URI handler function
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri_context</parameter>&nbsp;:</term>
<listitem><simpara> URI handler context data
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error_handler</parameter>&nbsp;:</term>
<listitem><simpara> error handler function
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error_data</parameter>&nbsp;:</term>
<listitem><simpara> error handler data
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>defaults</parameter>&nbsp;:</term>
<listitem><simpara> namespaces to initialise
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new namespace stack or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-init" role="function">
<title>raptor_namespaces_init ()</title>
<indexterm zone="raptor-namespaces-init"><primary>raptor_namespaces_init</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_namespaces_init              (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         const <link linkend="raptor-uri-handler">raptor_uri_handler</link> *uri_handler,
                                                         <link linkend="void">void</link> *uri_context,
                                                         <link linkend="raptor-simple-message-handler">raptor_simple_message_handler</link> error_handler,
                                                         <link linkend="void">void</link> *error_data,
                                                         <link linkend="int">int</link> defaults);</programlisting>
<para>
Initialise a namespaces stack some optional common namespaces.
</para>
<para>
<parameter>defaults</parameter> can be 0 for none, 1 for just XML, 2 for RDF, RDFS, OWL
and XSD (RDQL uses this) or 3+ undefined.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="raptor-namespace-stack"><type>raptor_namespace_stack</type></link> to initialise
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri_handler</parameter>&nbsp;:</term>
<listitem><simpara> URI handler function
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri_context</parameter>&nbsp;:</term>
<listitem><simpara> context for URI handler
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error_handler</parameter>&nbsp;:</term>
<listitem><simpara> error handler function
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error_data</parameter>&nbsp;:</term>
<listitem><simpara> context for error handler
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>defaults</parameter>&nbsp;:</term>
<listitem><simpara> namespaces to initialise.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on error
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-clear" role="function">
<title>raptor_namespaces_clear ()</title>
<indexterm zone="raptor-namespaces-clear"><primary>raptor_namespaces_clear</primary></indexterm><programlisting><link linkend="void">void</link>                raptor_namespaces_clear             (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);</programlisting>
<para>
Empty a namespace stack of namespaces and any other resources.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-free-namespaces" role="function">
<title>raptor_free_namespaces ()</title>
<indexterm zone="raptor-free-namespaces"><primary>raptor_free_namespaces</primary></indexterm><programlisting><link linkend="void">void</link>                raptor_free_namespaces              (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);</programlisting>
<para>
Destructor - destroy a namespace stack</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-start-namespace" role="function">
<title>raptor_namespaces_start_namespace ()</title>
<indexterm zone="raptor-namespaces-start-namespace"><primary>raptor_namespaces_start_namespace</primary></indexterm><programlisting><link linkend="void">void</link>                raptor_namespaces_start_namespace   (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *nspace);</programlisting>
<para>
Start a namespace on a stack of namespaces.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>nspace</parameter>&nbsp;:</term>
<listitem><simpara> namespace to start
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-start-namespace-full" role="function">
<title>raptor_namespaces_start_namespace_full ()</title>
<indexterm zone="raptor-namespaces-start-namespace-full"><primary>raptor_namespaces_start_namespace_full</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_namespaces_start_namespace_full
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         unsigned <link linkend="char">char</link> *ns_uri_string,
                                                         <link linkend="int">int</link> depth);</programlisting>
<para>
Create a new namespace and start it on a stack of namespaces.
</para>
<para>
See <link linkend="raptor-new-namespace"><function>raptor_new_namespace()</function></link> for the meanings of <parameter>prefix</parameter>,
<parameter>ns_uri_string</parameter> and <parameter>depth</parameter> for namespaces.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix</parameter>&nbsp;:</term>
<listitem><simpara> new namespace prefix (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns_uri_string</parameter>&nbsp;:</term>
<listitem><simpara> new namespace URI (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>depth</parameter>&nbsp;:</term>
<listitem><simpara> new namespace depth
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-end-for-depth" role="function">
<title>raptor_namespaces_end_for_depth ()</title>
<indexterm zone="raptor-namespaces-end-for-depth"><primary>raptor_namespaces_end_for_depth</primary></indexterm><programlisting><link linkend="void">void</link>                raptor_namespaces_end_for_depth     (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="int">int</link> depth);</programlisting>
<para>
End all namespaces at the given depth in the namespace stack.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>depth</parameter>&nbsp;:</term>
<listitem><simpara> depth
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-get-default-namespace" role="function">
<title>raptor_namespaces_get_default_namespace ()</title>
<indexterm zone="raptor-namespaces-get-default-namespace"><primary>raptor_namespaces_get_default_namespace</primary></indexterm><programlisting><link linkend="raptor-namespace">raptor_namespace</link>*   raptor_namespaces_get_default_namespace
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack);</programlisting>
<para>
Get the current default namespace in-scope in a stack.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="raptor-namespace"><type>raptor_namespace</type></link> or NULL if no default namespace is in scope
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-find-namespace" role="function">
<title>raptor_namespaces_find_namespace ()</title>
<indexterm zone="raptor-namespaces-find-namespace"><primary>raptor_namespaces_find_namespace</primary></indexterm><programlisting><link linkend="raptor-namespace">raptor_namespace</link>*   raptor_namespaces_find_namespace    (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         <link linkend="int">int</link> prefix_length);</programlisting>
<para>
Find a namespace in a namespace stack by prefix.
</para>
<para>
Note that this uses the <parameter>length</parameter> so that the prefix may be a prefix (sic)
of a longer string.  If <parameter>prefix</parameter> is NULL, the default namespace will
be returned if present, <parameter>prefix_length</parameter> length is ignored in this case.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix</parameter>&nbsp;:</term>
<listitem><simpara> namespace prefix to find
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix_length</parameter>&nbsp;:</term>
<listitem><simpara> length of prefix.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="raptor-namespace"><type>raptor_namespace</type></link> for the prefix or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-find-namespace-by-uri" role="function">
<title>raptor_namespaces_find_namespace_by_uri ()</title>
<indexterm zone="raptor-namespaces-find-namespace-by-uri"><primary>raptor_namespaces_find_namespace_by_uri</primary></indexterm><programlisting><link linkend="raptor-namespace">raptor_namespace</link>*   raptor_namespaces_find_namespace_by_uri
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-uri">raptor_uri</link> *ns_uri);</programlisting>
<para>
Find a namespace in a namespace stack by namespace URI.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns_uri</parameter>&nbsp;:</term>
<listitem><simpara> namespace URI to find
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="raptor-namespace"><type>raptor_namespace</type></link> for the URI or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-namespace-in-scope" role="function">
<title>raptor_namespaces_namespace_in_scope ()</title>
<indexterm zone="raptor-namespaces-namespace-in-scope"><primary>raptor_namespaces_namespace_in_scope</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_namespaces_namespace_in_scope
                                                        (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         const <link linkend="raptor-namespace">raptor_namespace</link> *nspace);</programlisting>
<para>
Test if a given namespace is in-scope in the namespace stack.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>nspace</parameter>&nbsp;:</term>
<listitem><simpara> namespace
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if the namespace is in scope.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-new-namespace" role="function">
<title>raptor_new_namespace ()</title>
<indexterm zone="raptor-new-namespace"><primary>raptor_new_namespace</primary></indexterm><programlisting><link linkend="raptor-namespace">raptor_namespace</link>*   raptor_new_namespace                (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         unsigned <link linkend="char">char</link> *prefix,
                                                         unsigned <link linkend="char">char</link> *ns_uri_string,
                                                         <link linkend="int">int</link> depth);</programlisting>
<para>
Constructor - create a new namespace from a prefix and URI string.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix</parameter>&nbsp;:</term>
<listitem><simpara> namespace prefix string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns_uri_string</parameter>&nbsp;:</term>
<listitem><simpara> namespace URI string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>depth</parameter>&nbsp;:</term>
<listitem><simpara> depth of namespace in the stack
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="raptor-namespace"><type>raptor_namespace</type></link> or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-free-namespace" role="function">
<title>raptor_free_namespace ()</title>
<indexterm zone="raptor-free-namespace"><primary>raptor_free_namespace</primary></indexterm><programlisting><link linkend="void">void</link>                raptor_free_namespace               (<link linkend="raptor-namespace">raptor_namespace</link> *ns);</programlisting>
<para>
Destructor - destroy a namespace.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespace-copy" role="function">
<title>raptor_namespace_copy ()</title>
<indexterm zone="raptor-namespace-copy"><primary>raptor_namespace_copy</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_namespace_copy               (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="int">int</link> new_depth);</programlisting>
<para>
Copy a namespace to a new namespace stack with a new depth.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>new_depth</parameter>&nbsp;:</term>
<listitem><simpara> new depth
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespace-get-uri" role="function">
<title>raptor_namespace_get_uri ()</title>
<indexterm zone="raptor-namespace-get-uri"><primary>raptor_namespace_get_uri</primary></indexterm><programlisting><link linkend="raptor-uri">raptor_uri</link>*         raptor_namespace_get_uri            (const <link linkend="raptor-namespace">raptor_namespace</link> *ns);</programlisting>
<para>
Get the namespace URI.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> namespace URI or NULL
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespace-get-prefix" role="function">
<title>raptor_namespace_get_prefix ()</title>
<indexterm zone="raptor-namespace-get-prefix"><primary>raptor_namespace_get_prefix</primary></indexterm><programlisting>const unsigned <link linkend="char">char</link>* raptor_namespace_get_prefix        (const <link linkend="raptor-namespace">raptor_namespace</link> *ns);</programlisting>
<para>
Get the namespace prefix.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> prefix string or NULL
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespace-get-counted-prefix" role="function">
<title>raptor_namespace_get_counted_prefix ()</title>
<indexterm zone="raptor-namespace-get-counted-prefix"><primary>raptor_namespace_get_counted_prefix</primary></indexterm><programlisting>const unsigned <link linkend="char">char</link>* raptor_namespace_get_counted_prefix
                                                        (const <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="size-t">size_t</link> *length_p);</programlisting>
<para>
Get the namespace prefix and length.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length_p</parameter>&nbsp;:</term>
<listitem><simpara> pointer to store length or NULL
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> prefix string or NULL
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespaces-format" role="function">
<title>raptor_namespaces_format ()</title>
<indexterm zone="raptor-namespaces-format"><primary>raptor_namespaces_format</primary></indexterm><programlisting>unsigned <link linkend="char">char</link>*      raptor_namespaces_format            (const <link linkend="raptor-namespace">raptor_namespace</link> *ns,
                                                         <link linkend="size-t">size_t</link> *length_p);</programlisting>
<para>
Format a namespace in an XML style into a newly allocated string.
</para>
<para>
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.
</para>
<para>
If <parameter>length_p</parameter> is not NULL, the length of the string is
stored in the address it points to.
</para>
<para>
See also <link linkend="raptor-new-namespace-parts-from-string"><function>raptor_new_namespace_parts_from_string()</function></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length_p</parameter>&nbsp;:</term>
<listitem><simpara> pointer to length (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> namespace formatted as newly allocated string or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-iostream-write-namespace" role="function">
<title>raptor_iostream_write_namespace ()</title>
<indexterm zone="raptor-iostream-write-namespace"><primary>raptor_iostream_write_namespace</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_iostream_write_namespace     (<link linkend="raptor-iostream">raptor_iostream</link> *iostr,
                                                         <link linkend="raptor-namespace">raptor_namespace</link> *ns);</programlisting>
<para>
Write a formatted namespace to an iostream</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>iostr</parameter>&nbsp;:</term>
<listitem><simpara> raptor iosteram
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ns</parameter>&nbsp;:</term>
<listitem><simpara> namespace to write
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-new-namespace-parts-from-string" role="function">
<title>raptor_new_namespace_parts_from_string ()</title>
<indexterm zone="raptor-new-namespace-parts-from-string"><primary>raptor_new_namespace_parts_from_string</primary></indexterm><programlisting><link linkend="int">int</link>                 raptor_new_namespace_parts_from_string
                                                        (unsigned <link linkend="char">char</link> *string,
                                                         unsigned <link linkend="char">char</link> **prefix,
                                                         unsigned <link linkend="char">char</link> **uri_string);</programlisting>
<para>
Parse a string containin an XML style namespace declaration
into a namespace prefix and URI.
</para>
<para>
The string is of the form xmlns:prefix="uri",
xmlns="uri", xmlns:prefix="" or xmlns="".
The quotes can be single or double quotes.
</para>
<para>
Two values are returned from this function into *<parameter>prefix</parameter> and
*<parameter>uri_string</parameter> neither of which may be NULL.
</para>
<para>
See also <link linkend="raptor-namespaces-format"><function>raptor_namespaces_format()</function></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> string to parse
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>prefix</parameter>&nbsp;:</term>
<listitem><simpara> pointer to location to store namespace prefix
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri_string</parameter>&nbsp;:</term>
<listitem><simpara> pointer to location to store namespace URI
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="raptor-namespace-stack" role="typedef">
<title>raptor_namespace_stack</title>
<indexterm zone="raptor-namespace-stack"><primary>raptor_namespace_stack</primary></indexterm><programlisting>raptor_namespace_stack* raptor_namespace_stack;
</programlisting>
<para>
Raptor XML Namespace Stack class</para>
<para>

</para></refsect2>
<refsect2 id="raptor-namespaces-qname-from-uri" role="function">
<title>raptor_namespaces_qname_from_uri ()</title>
<indexterm zone="raptor-namespaces-qname-from-uri"><primary>raptor_namespaces_qname_from_uri</primary></indexterm><programlisting><link linkend="raptor-qname">raptor_qname</link>*       raptor_namespaces_qname_from_uri    (<link linkend="raptor-namespace-stack">raptor_namespace_stack</link> *nstack,
                                                         <link linkend="raptor-uri">raptor_uri</link> *uri,
                                                         <link linkend="int">int</link> xml_version);</programlisting>
<para>
Make an appropriate XML Qname from the namespaces on a namespace stack
</para>
<para>
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.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>nstack</parameter>&nbsp;:</term>
<listitem><simpara> namespace stack
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> URI to use to make qname
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>xml_version</parameter>&nbsp;:</term>
<listitem><simpara> XML Version
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="raptor-qname"><type>raptor_qname</type></link> for the URI or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
