<intro xmlns="http://bauman.zapto.org/~syd/XML-xmp-ns"> <greeting xmlns="http://bauman.zapto.org/~syd/XML-xmp-ns"> <w xmlns="http://www.tei-c.org/ns/1.0">Hello</w> <w xmlns="http://www.tei-c.org/ns/1.0">World</w> <pc xmlns="http://www.tei-c.org/ns/1.0">!</pc> </greeting> </intro>
<syd:intro xmlns:syd="http://bauman.zapto.org/~syd/XML-xmp-ns" xmlns:tei="http://www.tei-c.org/ns/1.0"> <syd:greeting> <tei:w>Hello</tei:w> <tei:w>World</tei:w> <tei:pc>!</tei:pc> </syd:greeting> </syd:intro>
<syd:intro xmlns:syd="http://bauman.zapto.org/~syd/XML-xmp-ns" xmlns="http://www.tei-c.org/ns/1.0"> <syd:greeting> <w>Hello</w> <w>World</w> <pc>!</pc> </syd:greeting> </syd:intro>
<intro xmlns="http://bauman.zapto.org/~syd/XML-xmp-ns" xmlns:tei="http://www.tei-c.org/ns/1.0"> <greeting> <tei:w>Hello</tei:w> <tei:w>World</tei:w> <tei:pc>!</tei:pc> </greeting> </intro>
<TEI xmlns="http://www.tei-c.org/ns/1.0"> <!-- ... --> </TEI>
Namespaces are in effect the genus name for an XML element. If you’re operating colloquially within a single genus (your whole document is in TEI, for instance), then you can get away with only giving the species name. But if you’re actually processing documents with software, you always need to specify both. So how do we do this?
The first example shows us how to specify the namespace on every element as it occurs.
In this case, you use the @xmlns attribute, whose content is your namespace
(which is always a url). This is very bulky, however, and probably will make your
document harder to read. So we can specify two different namespaces at the top of
our
document, as you can see in the second example.
At the top of your document, you can specify the tei:xmlns and the xmlns you created (in this case syd:xmlns). Then, whenever you use an element, you just need to use the tei: or syd: prefixes to specify the namespace. The third example shows you how to specify one namespace as the default and the alternate namespace as the one with the prefix. This way, you only need to use a prefix for one set of elements. The final example is the TEI namespace declaration that is used on most TEI documents.