Next / Previous / Contents / Shipman's homepage

4.4. Global declarations

Because Python does not have constants per se, we use a naming convention: the names of constants use all capital letters, with “_” as the word separator.

litdocbook5
# - - - - -   M a n i f e s t   c o n s t a n t s

4.4.1. DB5_NS

The DocBook 5.0 namespace URI.

litdocbook5
DB5_NS = 'http://docbook.org/ns/docbook'

4.4.2. nsWrap: Namespace-wrap function

This function combines a namespace URI and a local name to return a fully qualified name. This notation was invented by James Clark: the namespace Uniform Resource Identifier is wrapped in “{...}”, folowed by the local name.

litdocbook5
def nsWrap(ns, local):
    '''Combine an NSURI and a local name.
    '''
    return '{{{0}}}{1}'.format(ns, local)

4.4.3. dbWrap(): Wrap a DocBook name

Given a DocBook 5 local name, returns the fully qualified name.

litdocbook5
def dbWrap(local):
    '''Convert a DocBook 5 name to a QName.
    '''
    return nsWrap(DB5_NS, local)

4.4.4. PROG_ELT

Name of the programlisting element, which is in the DocBook namespace.

litdocbook5
PROG_ELT = dbWrap('programlisting')

4.4.5. ROLE_ATTR

Name of the role attribute.

litdocbook5
ROLE_ATTR = 'role'

4.4.6. ROLE_PREFIX

The initial part of the role attribute that identifies the destination file.

litdocbook5
ROLE_PREFIX = "outFile:"