ZedAI Primer: Modules and Namespaces

From zedwiki

Jump to: navigation, search

Contents

  1. 2.1. A more complex document
  2. 2.2. Schemas and modules
  3. 2.3. Including other markup: namespaces

2.1 A more complex document

Our first example Z39.98-AI document included almost nothing beyond the core Z39.98-2012 modules. Real information resources will require much more than this, of course, and Z39.98-AI profiles will provide a variety of markup constructs to represent those structures. Here is a slightly more complex Z39.98-AI document that demonstrates this:

Example 2.1 - A more complex Z39.98-AI document

<document xmlns="http://www.daisy.org/ns/z3998/authoring/"
          xmlns:its="http://www.w3.org/2005/11/its" xml:lang="en">
  <head>
    <meta rel="z3998:profile" resource="http://www.daisy.org/z3998/2012/auth/profiles/book/1.0/">
        <meta property="z3998:name" content="book"/>
        <meta property="z3998:version" content="1.0"/>
    </meta>
    <meta rel="z3998:rdfa-context" resource="http://www.daisy.org/z3998/2012/vocab/context/default/"/>
    <meta property="dc:identifier" content="daisy-z2011-book-001" />
    <meta property="dc:publisher" content="DAISY Consortium" />
    <meta property="dc:date" content="2011-07-27T18:50:05Z" />
  </head>
  <body>
    <frontmatter>
      <section>
        <h property="dcterms:title">Ulysses: the condensed edition</h>
        <pagebreak xml:id="pR1" value="i" />
      </section>
      <toc>
        <h>Table of contents</h>
        <entry>
          Chapter 1
          <ref ref="p1">1</ref>
        </entry>
        <entry>
          Chapter 2
          <ref ref="p3">3</ref>
        </entry>
        <pagebreak xml:id="pR2" value="ii" />
      </toc>
    </frontmatter>
    <bodymatter>
      <section>
        <pagebreak xml:id="p1" value="1" />
        <h>Chapter 1</h>
        <p> Stately, plump Buck Mulligan came from the stairhead, bearing a
          bowl of lather on which a mirror and a razor lay crossed. He held
          the bowl aloft and intoned: 
          <quote xml:lang="la" its:translate="no">INTROIBO AD ALTARE DEI.</quote>
        </p>
        <pagebreak value="2" />
      </section>
      <section>
        <pagebreak xml:id="p3" value="3" />
        <h>Chapter 2</h>
        <p> Yes I said yes I will Yes. </p>
      </section>
    </bodymatter>
  </body>
</document>

2.2 Schemas and modules

Earlier vocabularies such as XHTML 1.0 (used in DAISY 2.02) and DTBook (used in ANSI/NISO Z39.98-2005) were based on Document Type Definitions (DTDs). Z39.98-2012 is based on a modularly-constructed schemas. Schemas can do more than DTDs: they are namespace aware, they allow the expression of intricate and complex content model constraints, and they support datatypes. All Z39.98-AI profiles define their markup using schemas in any combination of four different schema languages: RelaxNG, NVDL, W3C XML Schema, and ISO Schematron.

Schema languages naturally lend themselves to modular designs for markup languages. This means that there are multiple independent schema documents, each of which defines a set of elements and/or attributes that form a functional group. These modules can then be combined (composed) into a single vocabulary through a master "driver" schema document that brings the individual modules together and defines their interrelations. This kind of architecture will be familiar to those accustomed to object-oriented software design.

Every Z39.98-AI profile is based on the Z39.98-2012 abstract document model, as expressed in the Z39.98-2012 core modules. This means that every profile will use the Z39.98-2012 core modules in its master schema to some degree or another. While there are a very few elements that must be included in every profile (e.g., the document element document), profiles are free to include other Z39.98-2012 core modules that are appropriate to the kind of information resource the profile is designed to handle. In the case of the book profile, the main Z39.98-2012 modules used include, among others, the ones defining basic text structures (headings, paragraphs, etc.), tables, notes, pagination, and internationalization attributes.

Schema modules specifically provided with the profile are designed to contain the markup definitions for targeted structures. In our sample document we see one such case: the table of contents:

Example 2.2 - Table of contents from example document

<toc>
  <h>Table of contents</h>
  <entry>
    Chapter 1
    <ref ref="p1">1</ref>
  </entry>
  <entry>
    Chapter 2
    <ref ref="p3">3</ref>
  </entry>
  <pagebreak xml:id="pgR2" value="ii" />
</toc>

The schema module for table of contents (z3998-toc) contains the definitions for the toc, tocentry, label, and pageref elements and their attributes. The book profile master schema then includes this module and defines that toc can occur within frontmatter. In this way the table of contents module is integrated within the book profile's markup model. Note also that the table of contents module itself draws upon constructs from other modules. In our example, the toc includes an element from a different Z38.86-AI module: the heading element h. The table of contents module brings this into the content model for toc.

2.3 Including other markup: namespaces

So far, all the elements and attributes we have looked at are defined in schema modules that are part of the Z39.98-2012 specification, and hence are all in the default Z39.98-AI namespace. Just as the book profile brings in the table of contents module, so it can also bring in schema modules from other markup languages. In such a case, the elements and attributes from the other markup languages are distinguished by different namespaces.

Our example document uses one attribute from a different namespace: the translate attribute defined by the Internationalization Tag Set (ITS) of the W3C. This attribute is bound to the ITS namespace by the its: prefix, which itself is declared in the document's root element:

Example 2.3 - Declaration and use of the ITS namespace

<document xmlns="http://www.daisy.org/ns/z3998/authoring/"
          xmlns:its="http://www.w3.org/2005/11/its" xml:lang="en">
  …
  <body>
    …
    <bodymatter>
      <section>
        <p> Stately, plump Buck Mulligan came from the stairhead, bearing a
          bowl of lather on which a mirror and a razor lay crossed. He held
          the bowl aloft and intoned: 
          <quote xml:lang="la" its:translate="no">INTROIBO AD ALTARE DEI.</quote>
        </p>
      </section>
    </bodymatter>
  </body>
</document>

There is no limitation to the number of different schema modules that can be combined in a profile, and there is no limitation to the number of namespaces from which these may draw. Schema modules can be taken from non-DAISY namespaces (MathML, for example).


Primer Table of Contents

  1. Z39.98-AI_Profiles
  2. Modules and Namespaces
  3. Adding Semantic Inflections
  4. Features
  5. Metadata
Personal tools