XML technologies / ePUB / Open Publication Format / Navigation / Logical hierarchies

(Excerpt from “E-Books mit ePUB ─ Von Word zum E-Book mit XML” by Dr. Victor Wang)

First consider a normal hierarchy:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="de" dir="lfr">   ①
  <head>
     <meta name="dtb:uid" content="ebookID"/>                              ②
     <meta name="dtb:depth" content="2"/>                                  ③
     <meta name="dtb:totalPageCount" content="0"/>                         ④
     <meta name="dtb:maxPageNumber" content="0"/>                          ⑤
  </head>
  <docTitle>                                                               ⑥
     <text>Charles Darwin</text>
  </docTitle>
  <navMap id="hierarchie">                                                 ⑦
     <navPoint id="kap00001" playOrder="1">
        <navLabel>
           <text>1. Leben und Werk</text>
        </navLabel>
        <content src="../ops/dokument.htm#kap00001"/>
        <navPoint id="kap00002" playOrder="2">
           <navLabel>
              <text>1.1. Kindheit und Studium</text>
           </navLabel>
           <content src="../ops/dokument.htm#kap00002"/>
        </navPoint>
        <navPoint id="kap00003" playOrder="3">
           <navLabel>
              <text>1.2. Die Reise mit der HMS Beagle</text>
           </navLabel>
           <content src="../ops/dokument.htm#kap00003"/>
        </navPoint>
        <navPoint id="kap00004" playOrder="4">
           <navLabel>
              <text>1.3. Zurück in England – Anfänge der Evolutionstheorie</text>
           </navLabel>
           <content src="../ops/dokument.htm#kap00004"/>
        </navPoint>
        <navPoint id="kap00005" playOrder="5">
           <navLabel>
              <text>1.4. Rückzug nach Down House</text>
           </navLabel>
           <content src="../ops/dokument.htm#kap00005"/>
        </navPoint>
        <navPoint id="kap00006" playOrder="6">
           <navLabel>
              <text>1.5. Über die Entstehung der Arten</text>
           </navLabel>
           <content src="../ops/dokument.htm#kap00006"/>
        </navPoint>         
        . . .
     </navPoint>
     . . .
  </navMap>
</ncx> 

Code example: NCX structure

The root <ncx> has three attributes at ①. NCX version is fixed, currently version="2005-1"; the other two set general properties: xml:lang sets language and dir reading direction, here the Western default ltr (“left to right”). The document also declares its default namespace xmlns="http://www.daisy.org/z3986/2005/ncx/".

The following element <head> contains metadata expressed through generic <meta> elements in the NCX namespace. The NCX element <smilCustomTest> is not used in OPF. Use these four NCX metadata entries in OPF:

Metadata is followed at ⑥ by <docTitle>, the NCX title.

Next, <navMap> at ⑦ describes navigation hierarchy. Each level uses a <navPoint> containing a title <navLabel>, a content reference <content> and optional nested <navPoint> elements. Here is a three-level hierarchy:

<!-- Ebene 1 -->
<navPoint playOrder="3" id="kap010000">
  <navLabel>
      <text>Kapitel 1</text>
  </navLabel>
  <content src="kap01.html"/>
  <!-- Ebene 2 -->
  <navPoint playOrder="4" id="kap010100">
     <navLabel>
         <text>Kapitel 1.1</text>
     </navLabel>
     <content src="kap01-01.html"/>
     <!-- Ebene 3 -->
     <navPoint playOrder="5" id="kap010101">
        <navLabel>
            <text>Kapitel 1.1.1</text>
        </navLabel>
        <content src="kap01-01-01.html"/>
     </navPoint>
     . . .   
  </navPoint>
  . . .   
</navPoint> 

Code example: Hierarchical <navPoint> structure in NCX

The navigation point <navPoint> at ⑦ represents a logical level. Its required attribute playOrder is an integer specifying playback order. The required attribute id uniquely identifies it.

Within <navPoint>, the title is a child <navLabel>. Multilingual publications may provide several <navLabel> with language attributes xml:lang or dir=rtl|ltr. The actual title text is separate in <text>.

The second child <content> at ⑧ references the target content file. The required attribute src must contain a valid target URI.

This simple recursive structure represents almost any hierarchy. Choose a reasonable depth: overly detailed trees become cumbersome and opaque. Who wants seven or more levels, perhaps numbered Kapitel 1.2.3.4.5.6.7?

 

 

 

 

back to top