iBooks: What's a namespace?

You can think of namespaces as vocabularies.

Namespaces define the XML vocabularies that contain the elements and attributes you're using in the EPUB’s content documents. Each namespace is declared using a URL and the attribute xmlns or xmlns:. For example, xmlns:xhtml="http://www.w3.org/1999/xhtml".

In the above declaration, xmlns: is the attribute and xhtml is its prefix. After you declare it, you can use the prefix in front of any element or attribute name separated by a colon. This identifies which XML vocabulary that element or attribute is referencing. The following excerpt of the EPUB’s OPF file illustrates how you can use the prefix:

<?xml version="1.0" encoding="utf-8"?>

<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="bookid" version="3.0">

	<metadata xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" >


		<dc:identifier id="bookid">0123456789</dc:identifier>



In addition to the standard OPF namespace, the above excerpt includes the Dublin Core namespace (xmlns:dc="http://purl.org/dc/elements/1.1/“). This is used to specify metadata attributes within the OPF.
If a delivery ends in an error related to an element or attribute that’s not allowed, the specific element or attribute you're using might not be in the namespace vocabularies declared in the EPUB. To resolve the issue, change the element or attribute to one that is valid.

Published Date: