
<bk:book>
<bk:title>XML Sample</bk:title> <bk:pages>210</bk:pages>
<authr:firstname>John</authr:firstname> <authr:lastname>Smith</authr:lastname> <authr:title>Mr</authr:title>
</authr:author> </bk:book>
In the example above, the <TITLE> tag is used twice, but in a different context, once within the <AUTHOR> element and once within the <BOOK> element. Note the use of the xmlns keyword in the namespace declaration. The XML recommendation does not specify whether a namespace declaration should point to a valid URI (Uniform Resource Identifier), only that it should be unique and persistent. There is not guarantee that the URI will point to a valid URI.
In the example, in order to illustrate the relationship of each element to a given namespace, we chose to specify the relevant namespace prefix before each element. However, it is assumed that once a prefix is applied to an element name, it applies to all descendants of that element unless it is
Example 2-2 A namespace example using namespace prefix
<?xml version”1.0”?>
<title>XML & WebSphere</title> <pages>210</pages>
<firstname>Joe</firstname>
<lastname>Bloggs</lastname>
<title>Mr</title> </authr:author>
</bk:book>
In this example, it is clear that all elements within the <BOOK> element are associated with the bk namespace, except for the elements within the <AUTHOR> element which belong to the authr namespace.
24 The XML Files: Development of XML/XSL Applications Using WebSphere Studio