DTD Tool Demo

The goal of this demo is to show how the DTD tool of the CLaRK system can be used.

Each document in the system is loaded with respect to some XML DTD. For this reason at least one DTD must be compiled in the system.

The layout (Tree and Text) of the documents in the system also depends on DTDs.

Demo 1: DTD Compilation

The goal here is to show how DTDs are compiled in the system.

In order to compile a DTD you have to perform the following steps:

  1. Select the Compile DTD tool from the menu item DTD - a standard File Chooser appears.
  2. Select file containing the DTD from the appropriate directory. In our case the demo directory Dtd - teixlite2x.dtd file.
  3. From Files of Type: combo box select the appropriate Encoding - ASCII Text File.
  4. Click on the Open button. If there is no DOCTYPE defined in the dtd, a dialog with list of all elements in the DTD appears and the user is asked to select the DOCTYPE - TEI.2 (the root element for documents using that DTD).

A message for successful compilation appears. DTD is saved in the system with the name of the file containing it.

Demo 2 : DTD viewing and editing

The goal here is to show how the user can view and edit DTDs in the system.

In order to view a DTD you have to perform the following steps:

  1. Select the Edit DTD tool from the menu item DTD - list of all DTDs compiled in the system appears.
  2. Select teixlite2x.dtd from the list of all DTDs. The information data is divided into four sections representing different parts of the DTDs (structure data, attributes data, entities data and processing-instructions data).

Each row in the tables describes exactly one feature and the user can edit it by double click.

Demo 3: Edit DTD Text Layout

Our goal here is to show how by editing the DTD text layout, the user can change the way, in which a document, loaded in the system, will appear on the screen.

This facility includes the following: moving to a new line before/after opening/closing tag, hiding some tags and/or their content.

In order to edit the DTD layout you have to perform the following steps:

  1. Select the Edit Text Layout tool from the menu item DTD - list of all DTDs compiled in the system appears.
  2. Select teixlite2x.dtd from the list of all DTDs. A table for editing the layout appears.The first column contains all tag names in the DTD. Each row represents the layout information for one tag.
  3. Select Open tag start in order the opening tag of the corresponding element to appear on a new line. Select it for div0, head, p, trailer and w elements.
  4. Select Open tag end in order the first child node of the corresponding node to appear on a new line (a new line after the opening tag).
  5. Select Close tag start in order the closing tag of the corresponding element to appear on a new line. Select it for div0 element.
  6. Select Close tag end in order a new line to be inserted after the closing tag.
  7. Select Is tag visible in order to make the tag to be visible or hidden on the screen. By default, the tag is visible.
  8. Select Are children visible in order to hide or visualize the content of the tag.
  9. Select the check box at the bottom of the window Use line offsets in order to have more comprehensive visualization. It suggests an additional white space to be inserted in front of the tags - the number of spaces can be set by the user. If chosen, white spaces are assigned to each tag, which appears on a new line and the length of the white space depends on the depth of the node in the DOM tree.

When a document is loaded, it obeys the layout, defined for its DTD. Note that later on this layout can be changed for the current view.

Here is an example of how the document will look like in our case:

Demo 4: Edit DTD Tree Layout

Our goal here is to show how by editing the DTD tree layout, the user can change the way, in which the document tree will be displayed on the screen.

Without a Tree Layout option activated the tree appears in the following way: element nodes are represented by their tag names, text nodes - by their text context. The nodes in the tree are colored in blue if the corresponding (DOM) nodes are valid with respect to the DTD, and colored in red otherwise. When a Tree Layout is activated the user can define the way each element node is represented in the tree.

In order to edit DTD tree layout you have to perform the following steps:

  1. Select the Edit Tree Layout tool from the menu item DTD - list of all DTDs compiled in the system appears.
  2. Select teixlite2x.dtd from the list of all DTDs. A table for editing the layout appears.The first column Element contains all tag names in the DTD. The second column Pattern defines what will be shown instead of the element - the Instructions button gives a short description of the text pattern syntax. The last column Color shows how the pattern will be colored. Each row represents the layout information for one tag.
  3. In the Pattern text field of head element write the following head : {text()} and select Red color.
  4. In the Pattern text field of p element write the following p type = {parent::*/@type} and select Cyan color.
  5. In the Pattern text field of pt element write the following {text()} and select Gray color.
  6. In the Pattern text field of w element write the following {text()} and select Green color.
  7. In the Pattern text field of trailer element write the following author : {text()} and select Magenta color.
  8. Enable the Layout from Enable Layout check box
  9. and press OK button.

Each layout can be enabled/disabled. When a layout is disabled the tree is shown as if there is no layout defined but it still remains in the memory and can be enabled later.

The layout is saved in treeLayout.lt file in the demo directory.

Below you can see how the above tree layout changes the tree appearance:

Tree Layout enabled

Tree Layout disabled