Next / Previous / Contents / Shipman's homepage

5.2. Structure of the input file

The DocBook 5.0 schema's elements are in this namespace:

http://docbook.org/ns/docbook

Certain standard elements such as xml:id are in this namespace:

http://www.w3.org/XML/1998/namespace

The primary input to this program is the title element for the entire work, and the title elements in all sections. Sections may appear as section, sect1, sect2, or sect3 elements.

In each case, the title element is wrapped in an info element. If we ignore the namespace qualifiers, here are some examples of XPath expressions describing places where a title element might occur:

/article/info/title
/article/section/info/title
/article/section/section/info/title
/article/section/section/section/info/title
/article/sect1/info/title
/article/sect1/sect2/info/title
/article/sect1/sect2/sect3/info/title

We'll also render the elements described in Section 5.4, “The report format”, such as code and application.

As parsed by lxml, each element and attribute name actually appears as “{nsuri}local”, where nsuri is the namespace URI (NSURI) and local is the local element name. For example, the .tag attribute of the article node will actually be:

{http://docbook.org/ns/docbook}article

Because id is a universal XML attribute, it is in the XML namespace, so its .tag will be:

{http://www.w3.org/XML/1998/namespace}id

Navigating within the XML tree in the presence of namespace qualifiers requires additional techniques.