As discussed earlier, XML allows you to create your own languages. However, what if
someone else has developed a schema that you want to use? There is the chance that
element names from this other schema will conflict with yours. XML has a solution for
this: namespaces. Namespaces allow you to make your elements globally unique. It
does this by attaching your element names to a Universal Resource Identifier (URI). A
Uniform Resource Locator (URL) is an example of a URI, as is a Uniform Resource
Name (URN). Even if you use an extremely common element name in your document,
such as name, you can make it globally unique by specifying a URI that you control.
XSQL uses a URN<oracle-xsql>for its namespace. You may have noticed it
in the examples:
<page connection=demo xmlns:xsql=urn:oracle-xsql>
The <xmlns:xsql> attribute signifies that some children elements of the page ele-
ment will belong to the XSQL namespace. Namespaces can overlapin fact, thats the
whole point. The following XSQL example shows this. This page uses both the XSQL
namespace and the Mike namespace.
<page connection=demo xmlns:xsql=urn:oracle-xsql
select * from emp where ename=SMITH
The output of this XSQL is shown above. Notice that the <xmlns:mike> attribute
is preserved but the <xmlns:xsql> namespace isnt. In the output, no member of the
XSQL namespace is present. The <xsql:query> element was replaced with the
results of the query. Because there are no members of the namespace in the document,
the XSQL page processor removes the attribute.
We spoke earlier about how XML allows you to create your own languages. These
languages are formally known as schemas. A schema is a definition of how elements in
your XML should relate to one another, what attributes are appropriate, and what
values are appropriate for nonempty elements. You can program very successfully in
XSQL without ever creating your own schema. At the least, its important to be con-
versant about schemas.
The XML documents that you have seen so far are very simple, but XML can be very
complex. The purpose of a schema is to rein in that complexity. This makes it easier for
applications to be able to consume the XMLthey know what they are expecting.
Introducing Oracle XSQL
271209 Ch01.F 12/9/02 2:00 PM Page 21