4 Understanding XML Namespaces

XML namespaces are a mechanism that ensures that there are no name conflicts (or ambiguity) when combining XML documents or referencing an XML element. Oracle Data Service Integrator fully supports XML namespaces and includes namespaces in the queries generated in Workshop for WebLogic.

This section includes the following topics:

4.1 Introducing XML Namespaces

Namespaces provide a mechanism to uniquely distinguish names used in XML documents. XML namespaces appear in queries as a namespace string followed by a colon. The W3C uses specific namespace prefixes to identity W3C XQuery data types and functions. In addition, Oracle has defined the fn-bea: namespace prefix to uniquely identify Oracle-supplied functions.

Table 4-1 lists the predefined XQuery namespaces used in Oracle Data Service Integrator queries.

Table 4-1 Predefined Namespaces in XQuery

Namespace Prefix Description Examples

The prefix for XQuery functions.


The prefix for Oracle Data Service Integrator-specific extensions to the standard set of XQuery functions.


The prefix for XML schema types.


For example, the xs:integer data type uses the XML namespace xs. Actually, xs is an alias (called a prefix) for the namespace URI.

XML namespaces ensure that names do not collide when combining data from heterogeneous XML documents. As an example, consider a document related to automobile manufacturers that contains the element <tires>. A similar document related to bicycle tire manufacturers could also contain a <tires> element.

Combining these documents would be problematic under most circumstances. XML namespaces easily avoid these types of name collisions by referring to the elements as <automobile:tires> and <bicycle:tires>.

4.1.1 Exploring XML Schema Namespaces

XML schema namespaces—including the target namespace—are declared in the schema tag. The following is an example using a schema created during metadata import:

<xsd:schema targetNamespace="http://temp.openuri.org/SampleApp/CustOrder.xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified">

The second line declares the target namespace using the targetNamespace attribute. It this case, the target namespace is:


The third line of the schema contains the default namespace, which is the namespace of all the elements that do not have an explicit prefix in the schema.

For example, if you see the following element in a schema document:

<element name="appliance" type="string"/>

the element element belongs to the default namespace, as do unprefixed types such as string.

The fourth line of the schema binds the xsd prefix to the standard XML Schema URI. The fifth line of the schema contains a namespace declaration which associates a URI with the bea prefix. There can be any number of these declarations in a schema.

References to types declared in this schema document must be prefixed, as illustrated by the following example:

<complexType name="AddressType">
      <element name="street_address" type="string"/>

<element name="address" type="bea:AddressType"/>

It is recommended that you create schemas with elementFormDefault="unqualified" and attributeFormDefault="unqualified". This enables you to move elements between namespaces by renaming a single complex element, instead of having to explicitly map every element.

4.2 Using XML Namespaces in Oracle Data Service Integrator Queries and Schemas

Oracle Data Service Integrator automatically generates the namespace declarations when generating a query. Oracle Data Service Integrator employs a simple scheme using labels ns0, ns1, ns2, and so forth. Although it is easy to change assigned namespace names, care must be taken to make sure that all uses of that particular namespace are changed.

When a Return type is created, by default it is qualified, meaning that the namespace of the outermost complex element appears in the schema.

Figure 4-1 Schema with Unqualified Attributes and Elements

Schema with Unqualified Attributes and Elements
Description of "Figure 4-1 Schema with Unqualified Attributes and Elements"

If you want attributes or nested elements to appear as qualified, you need to use an editor outside Workshop for WebLogic to modify the generated schema for either or both attributeFormDefault and elementFormDefault to be set to qualified.