www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
xmlagg
xmlattributes
xmladdattribute
xmlappendchildren
xmlconcat
xmlelement
xmlforest
xmlinsertafter
xmlinsertbefore
xmlreplace
xmltype.xmltype
xmltype.createnonsch...
xmltype.createschema...
xmltype.createxml
xmltype.existsnode
xmltype.extract
xmltype.getclobval
xmltype.getnamespace
xmltype.getnumval
xmltype.getrooteleme...
xmltype.getschemaurl
xmltype.getstringval
xmltype.isfragment
xmltype.isschemabase...
xmltype.isschemavali...
xmltype.isschemavali...
xmltype.schemavalida...
xmltype.setschemaval...
xmltype.toobject
xmltype.transform
xmlupdate
xper navigation
createxml
isentity
serialize_to_utf8_xm...
tidy_html
tidy_list_errors
updatexml
xml_add_system_path
xml_auto
xml_auto_dtd
xml_auto_schema
xml_create_tables_fr...
xml_cut
xml_doc_output_optio...
xml_get_system_paths
xml_load_mapping_sch...
xml_load_schema_decl
xml_namespace_scope
xml_persistent
xml_set_ns_decl
xml_template
xml_tree
xml_tree_doc
xml_tree_doc_media_t...
xml_uri_get
xml_validate_dtd
xml_validate_schema
xml_view_dtd
xml_view_schema
xmlsql_update
xpath_eval
xper_cut
xper_doc
xper_locate_words
xpf_extension
xpf_extension_remove
xquery_eval
xslt
xslt_format_number
xslt_sheet
xslt_stale
xte_head
xte_node
xte_node_from_nodebl...
xte_nodebld_acc
xte_nodebld_final
xte_nodebld_init
xtree_doc
XPATH & XQUERY

Functions Index

XMLType.getNamespace

Returns the namespace of the top level element providing the instance is schema-based rather than a fragment.
XMLType.getNamespace
Description

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.

Return Types

This function returns a wide string or NULL.

Examples
Factors that affect the result of getNamespace()

The following statements demonstrate how various circumstances may force getNamespace() to return NULL.

-- 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

See Also

XMLType.isFragment()