1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_XMLType.getNamespace">
<refmeta>
<refentrytitle>XMLType.getNamespace</refentrytitle>
<refmiscinfo>xml</refmiscinfo>
</refmeta>
<refnamediv>
<refname>XMLType.getNamespace</refname>
<refpurpose>Returns the namespace of the top level element providing the instance
is schema-based rather than a fragment.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_XMLType.getNamespace">
<funcprototype id="fproto_XMLType.getNamespace">
<funcdef><function>XMLType.getNamespace</function></funcdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_XMLType.getNamespace">
<title>Description</title>
<para>The member function returns the namespace URI of the top level element
providing that the given instance is schema-based and is well-formed.
This function returns NULL if the instance is a fragment.
If there are many top level elements then they may have different
namespace URIs and if there is no top level element then there is nothing
to return. It also returns NULL if the instance is non-schema based for compatibility.</para>
</refsect1>
<refsect1 id="ret_XMLType.getNamespace"><title>Return Types</title>
<para>This function returns a wide string or NULL.</para>
</refsect1>
<refsect1 id="examples_XMLType.getNamespace">
<title>Examples</title>
<example id="ex_XMLType.getNamespace"><title>Factors that affect the result of getNamespace()</title>
<para>The following statements demonstrate how various circumstances may
force getNamespace() to return NULL.</para>
<screen><![CDATA[
-- First of all, top level element may have a name with no namespace.
select XMLType('<local />').getNamespace()
_______________________________________________________________________________
NULL
-- Compatibility: the instance should be schema-based.
select XMLType('<z:qname xmlns:z="http://www.example.com/"/>').getNamespace()
_______________________________________________________________________________
NULL
-- This is schema-based, but top level element has no namespace.
select XMLType('<local />', 'http://www.example2.com/test.xsd').getNamespace()
_______________________________________________________________________________
NULL
-- Note that for XPATH processor return an empty string, not a NULL,
-- as a namespace uri of a name with no URI.
select xpath_eval('namespace-uri(.)', XMLType('<local />', 'http://www.example2.com/test.xsd'))
_______________________________________________________________________________
1 Rows. -- 00000 msec.
-- Schema-based instance with nonempty namespace URI.
select XMLType('<z:qname xmlns:z="http://www.example.com/"/>', 'http://www.example2.com/test.xsd').getNamespace()
_______________________________________________________________________________
http://www.example.com/
-- It also works with default namespace URIs.
select XMLType('<qname xmlns="http://www.example.com/"/>', 'http://www.example2.com/test.xsd').getNamespace()
_______________________________________________________________________________
http://www.example.com/
-- Finally, it returns NULL for fragments even if all top-level elements of
-- a fragment have identical namespace URIs.
select XMLType('
<z:qname xmlns:z="http://www.example.com/"/>
<z:qname xmlns:z="http://www.example.com/"/>',
'http://www.example2.com/test.xsd').getNamespace()
_______________________________________________________________________________
NULL
]]>
</screen>
</example>
</refsect1>
<refsect1 id="seealso_XMLType.getNamespace">
<title>See Also</title>
<para><link linkend="fn_XMLType.isFragment"><function>XMLType.isFragment()</function></link></para>
</refsect1>
</refentry>
|