Publishing Books Using XML Technologies
Dr. Herong Yang, Version 4.01

Variables Used in Book Source Files

This section describes variables used in book source files.

Variable Definitions and Replacements

Variables are special logics used by hyPub to assign text values in place and apply them in other places in the book source file.

There are 3 categories of variables used in hyPub:

  • Built-in Variables - Variables with text values assigned by hyPub automatically.
  • Required Variables - Variables that you must assign text values. hyPub will need those variables to process your book.
  • Optional Variables - Variables that you can assign text values and apply them only if you need them.

Defining Variables

In book source files, variables are defined using the following syntax:

<p class="variable" id="variableName">variableValue</p>

where "variableName" is the name of the variable, and "variableValue" is the value of the variable.

Do not use underscore characters "_" in variable names.

A variable definition must be done in a single text line. Currently, hyPub is not smart enough to parse multiple lines for variable definitions.

Recursive definitions of variables are not allowed.

The scope of a variable is limited to the container where it is defined.

If the same variable name is defined multiple times in the same container, the last definition wins.

Applying Variables

In book source files, variables can be applied (evaluated to their values) anywhere in the book source file using the following syntax:

__variableName__

where "variableName" is the name of the variable.

When an undefined variable is used in the book source file, hyPub will not give you compilation errors. It will simply ignore it.

When a variable is defined multiple nested levels, the definition of inner level wins.

hyPub Built-in Variables

Currently, hyPub supports 4 built-in variables:

  • __bookToc__ - The table of contents of the book, which will be generated automatically by hyPub with all chapters and sections in the book.
  • __chapterToc__ - The table of contents of the chapter, which will be generated automatically by hyPub with all sections in the chapter.
  • __fileName__ - The name of the final Web page files, which will be generated automatically by hyPub as "index" for the index page file, the chapter name for a chapter page file, and the section name of a section page file.
  • __chapterName__ - The Web page file of the current chapter, which will be generated automatically by hyPub. This will help you to build a link pointing back to the beginning of the chapter in a section block.

Required Variables

Currently, hyPub requires the following variables:

  • <p class="variable" id="title"> - Used at the Index level to define the title of the book.
  • <p class="variable" id="indexTitle"> - Used at the Index level to define the title of the index.
  • <p class="variable" id="chapterTitle"> - Used at the Chapter level to define the title of a chapter.
  • <p class="variable" id="sectionTitle"> - Used at the Section level to define the title of a section.
  • <p class="variable" id="pageTitle"> - Used at the Index, Chapter, or Section level to define the Web page title.
  • <p class="variable" id="version"> - Used at the Index level to define the version of the book.
  • <p class="variable" id="author"> - Used at the Index level to define the author of the book.
  • <p class="variable" id="copyright"> - Used at the Index level to define the copyright text of the book.
  • <p class="variable" id="homeUrl"> - Used at the Index level to define the URL of the Website where your book will be published.
  • <p class="variable" id="description"> - Used at the Index, Chapter or Section level to define the description text for the book, a chapter, or a section.
  • <p class="variable" id="keywords"> - Used at the Index, Chapter or Section level to define the key words for the book, a chapter, or a section.

Optional Variables

hyPub allows you to define your own variables in book source file, and apply them any where you want. For example, you may define some variables listed below:

<p class="variable" id="pi">3.141592653589793</p>
<p class="variable" id="myDomain">herongyang.com</p>

Table of Contents

 About This Book

 Ideas on Publishing Books using XML

 Overview of hyPub - A Simple XML Publishing Tool

Writing Book Contents in XHTML Source Files

 Book Source File Structure

Variables Used in Book Source Files

 Inserting Anchors in Book Source Files

 Transforming Book Source Files with XSL Technology

 Designing Web Page Layouts with Tables

 Controlling Web Page Appearance with CSS

 Sharing HTML Codes with JavaScript Files

 Generating Web Pages with hyPub

 Formatting Printable Documents with XSL-FO

 Generating PDF Documents with hyPub

 Areas of Future Improvements

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2007
Variables Used in Book Source Files