CaveScript Document Type Definitions

CaveScript XML
Document Type Definitions
Michael Lake
January 2000, Version 0.1


Introduction

This document details the CaveScript Document Type Definitions (DTDs) for cave surveys and cave maps. There are two DTDs:

  1. CaveSurvey DTD - which covers the survey of the cave and
  2. CaveMap DTD - which covers objects in the cave and which may appear on a cave map.

The CaveSurvey DTD in Section [->] defines the XML structure which describes cave survey data; the stations and their descriptions, shots, instruments, surveyors and hopefully everything that you would want to include in a cave survey. One might describe these things as the abstract, non-natural things about a cave survey.

The CaveMap DTD in Section [->] defines the XML structure which describes the objects in a cave which may appear on cave maps such as the walls, floor and roof features, speleothems, biota, geology etc. These are the things that you see in a cave, both natural and artificial.

Change History and Version Information

The change history and version information for CaveSurvey DTD and CaveMap DTD can be found at the start of Part I and Part II respectively.


Quick Summary of noweb Usage

Table [->] shows the noweb commands used to extract the code and documentation. The options supplied to noweb are listed in Table [->]. The Makefile is a more convenient way to perform the same tasks and is covered on page [->].


To create:Run:
Makefile: notangle -t4 -RMakefile DTD.nw > Makefile
CaveSurvey DTD: notangle -t4 -Rcavesurvey.dtd DTD.nw > CaveSurvey.dtd
CaveMap DTD: notangle -t4 -Rcavemap.dtd DTD.nw > CaveMap.dtd
Example XML file: notangle -t4 -Rmysurvey.xml DTD.nw > mysurvey.xml
Example XML file: notangle -t4 -Rmymap.xml DTD.nw > mymap.xml
LaTeX documentation noweave -t4 -delay -index DTD.nw > DTD.tex
latex DTD.tex
HTML documentation noweave -html -filter l2h -x DTD.nw | htmltoc > DTD.html
All the files: noweb DTD.nw
Quick summary of noweb usage [*]


notangle/noweave options
-t4 Copy tabs untouched from input to output, and use tabs for indentation.
Tabs get set to 8 by default in noweb.
-R extracts root chunk from noweb file
Options in notangle/noweave usage [*]

Defined chunks in this noweb document are listed in Section [->].

Interpreting noweb Cross References

Throughout the dvi and Postscript documentation you will see that each chunk of code is uniquely identified by a page number and an alphabetic sub-page reference. An example is:

10b <cavesurvey.dtd 9>+=== (15) 10a 11

This line tells us that we are now in code chunk 10b. This code chunk is on page 10 and it is the second code chunk defined on this page.

The construct <cavesurvey.dtd 9>+=== tells us that we are in a code chunk called cavesurvey.dtd, that its definition began in chunk 9 and the +=== means we are adding to its definition (noweb concatenates definitions with the same name in order of appearance).

At the right margin we find: (15) 10a 11

This tells us that the chunk we're defining is used within chunk 15, and that this current chunk is continued from chunk 10a and is continued in chunk 11.

At the end of each code chunk a %def is be used to define any variables within that code chunk that we want to cross reference. These defined variables get listed in the noweb index with a page number to where they were defined. The LaTeX hyperref package is being used so this page number will be a hyperlink and show as underlined.

Any defined variables enclosed in double square brackets like this [[variable]] in the documentation text becomes a hyperlink, again to the place where that variable is defined.


Makefile for DTD's and Documentation

[*]

The following Makefile provides a convenient way to create or update the code or documentation after modifications to the noweb source file rather than typing all the notangle or noweave commands. Code or documentation changes are done by making the modifications in the noweb source file and running the appropriate make command.

To extract the Makefile:

notangle -t4 -RMakefile DTD.nw > Makefile

Run ``make help'' to see what options there are.

For instance, after making changes to any of the DTD's via the noweb source file I run ``make dvi'' to see my changes in xdvi or do a ``make DTD'' to create the up-to-date DTD's. One generally never changes the output files directly (except for quick hacks).

<Makefile>=
#################################################################
# Makefile for creating CaveScript DTD's and their Documentation
#################################################################

# The noweb source file
NOWEB_SOURCE = DTD.nw

# If the user just types 'make' with no args then help, being the 
# first routine will be invoked.
help:
        @echo 'Usage: make [dtd examples dvi ps html all clean]'

# Create DTDs
dtd: $(NOWEB_SOURCE)
         @echo 'Creating CaveSurvey.dtd and CaveContent.dtd ...'
         notangle -t4 -Rcavesurvey.dtd $(NOWEB_SOURCE) | cpif CaveSurvey.dtd
         notangle -t4 -Rcavemap.dtd    $(NOWEB_SOURCE) | cpif CaveMap.dtd

# Create examples
examples: $(NOWEB_SOURCE)
         @echo 'Creating example XML files ...'
         notangle -t4 -Rmysurvey.xml $(NOWEB_SOURCE) | cpif  mysurvey.xml
         notangle -t4 -Rmymap.xml   $(NOWEB_SOURCE) | cpif  mymap.xml

# Create documentation
dvi: $(NOWEB_SOURCE)
         noweave -t4 -delay -index $(NOWEB_SOURCE) >| DTD.tex
         @echo  
         @echo 'Running "latex DTD.tex" ...'
         latex DTD.tex
         @echo  
         @echo 'You may need to run latex again.'
         @echo  
         @echo 'latex DTD.tex'
         @echo  

ps: dvi
        dvips DTD.dvi -o DTD.ps

html: $(NOWEB_SOURCE)
          noweave -html -filter l2h -index $(NOWEB_SOURCE) | htmltoc >| DTD.html

all: dtd ps html

clean:
        lintex

Notes and Ideas


The CaveMap DTD [*]

Scope

The CaveMap DTD defines the XML structure for Cave Map XML documents.

Cave Map documents use XML tags to encapsulate just about everything that we might wish to include on a cave map. Things such as wall detail, avens and cross sections, floor deposits, speleothems, text and even artistic elements such as shading and textures. The DTD for Cave Map XML fully describes these elements and how they can be used.

Information that is not included within the cave map document is the survey data. This is in cave survey XML files and is linked to via XML Xpointers and Xlinks.

Change History and Version Information

The version number here must match the latest version number in the change history below.

<cavemap version>= (U->)
<!-- Version number of this CaveMap DTD -->
<!ENTITY % version "0.1">

Date            Version         Change
01 Jan 2000: 0.1

Preface

Some comments are inserted at the start of the DTD files so that I'll know where these files came from.

Inserted at the start of the files is:

<cavemap preface>= (U->)
<!-- DTD for the CaveScript CaveMap XML -->
<!-- Author: Michael Lake, Mike.Lake@uts.edu.au -->
<!-- This file is generated from noweb source file DTD.nw -->

Parameter Entities

<cavemap.dtd>= [D->]
<cavemap preface>
<cavemap version>

Root Element Name

<cavemap.dtd>+= [<-D->]
<!-- ============ Root Element Name and Content ============ -->
<!ELEMENT CAVEMAP ( HEAD ) >


Defines CAVEMAP (links are to index).

An alternative CaveMap DTD would be the following:

<cavemap2.dtd>=
<!DOCTYPE CAVEMAP [
<!-- ============ Cave Map DTD ============ -->
<!ENTITY % CAVESURVEY   SYSTEM "cavesurvey.dtd">
<!ENTITY % CAVECONTENT  SYSTEM "cavecontent.dtd">
<!ENTITY % CAVESTANDARD SYSTEM "asf.dtd">

%CAVESURVEY; 
%CAVECONTENT;   
%CAVESTANDARD;
]>

where the cave survey, the contents of the cave and the cave mapping standards were all separated.

Example Fragment of CaveMap XML Document

All XML documents begin with the XML declaration and optionally a Document Type Definition which can be used to validate the document. Note that this DTD is different to the CaveSurvey DTD. The root element is CAVEMAP.

<mymap.xml>=
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CAVEMAP SYSTEM "CaveMap.dtd">

<CAVEMAP>
<mymap.xml east>
<mymap.xml west1>
<mymap.xml west2>
<mymap.xml loop>
<mymap.xml avens>
</CAVEMAP>

The Head Element

The HEAD element provides identifying information on the map. This would contain all the information that would normally be written in the title block of a cave map.

<cavemap.dtd>+= [<-D->]
<!-- ============ Title Black Information ============ -->
<!ELEMENT HEAD (TITLE, AREA, CAVE, DATE?, INSTRUMENTS, DRAWERS) >

Defines HEAD (links are to index).

An example of a title block is as follows:

W31 Sigma Cave
Wombeyan Caves NSW
Surveyed 1980 to 1999 by SUSS
Surveyors: ...
Drawn by M. Lake, P. Maynard 1999
Scale of original 1:200
Grade ASF 54
Date
Map No. 2W356
Surveyed length Surveyed depth

Survey Shots

Maps may also include the survey shots or legs, the data for which may be in CaveScript files.

src="tattered-survey.xml"

Walls

Element Structure

The following declares the element and attribute structures.

<cavemap.dtd>+= [<-D->]
<!-- ============ Passage Walls ============ -->
<!ELEMENT WALL  ( DATA+ ) >
<!ATTLIST WALL
          NAME  CDATA #IMPLIED
>

Data

The following declares the element and attribute structures.

<cavemap.dtd>+= [<-D->]
<!ELEMENT DATA  (#PCDATA) >
<!ATTLIST DATA
          REF   CDATA #REQUIRED
>

Example Fragment of CaveMap XML Document

The simplest wall is described by a WALL element which contains at least one DATA element. The content of the data element in its simplest form is a sequence of real numbers which are the (x,y) coordinates of points on the wall of the cave, measured with respect to the adjacent survey leg. The REF attribute tells us the from station and the to station of this leg.

<mymap.xml east>= (<-U)
<WALL NAME="Southern end of Eastern Wall">
        <DATA REF="85,86"> 1.0 0.0   1.0 4.0   0.7 6.0   1.0 8.0</DATA>
    <DATA REF="86">    0.0 0.0                              </DATA>
</WALL>

<WALL NAME="Northern end of Eastern Wall">
    <DATA REF="86,87"> 0.0 0.0   0.2 1.0   0.5 2.0   0.3 3.0</DATA>
    <DATA REF="87">    0.3 0.0                              </DATA>
    <DATA REF="87,88"> 0.3 1.0   0.4 2.0   0.5 3.0   0.0 6.0</DATA>
    <DATA REF="88,89"> 1.0 1.0   0.6 2.0                    </DATA>
    <DATA REF="89,90"> 0.5 0.0   0.4 3.0                    </DATA>
</WALL>

Note that the two wall sections here will be connected as one ends at (0,0) wrt 86 and the other begins at (0,0) wrt 86. However the join is not smooth (ie. it's derivative is not a contiguous curve).

The x_i values are the distances measured perpendicular to the survey leg, the y_i are how far along the survey leg the perpendicular is starting from the from station (see Figure [->]). That means that the y value at the from station is zero and the y value of the to station is the same as the shot length.


[picture]

(40,40)(70,70)(80,70) (80,70)(90,70)(100,120)

Relationship of the cave wall coordinates and the survey leg [*]


Looking along the survey leg from the from station to the to station distances to the left are defined to be negative and distances to the right to be positive.

In the example above the wall coordinates are with respect to the survey leg from station 85 to station 86. A distance of 0.0m along from stn 85 and -0.81m perpendicularly to the left is a wall point. The next point is 1.0m along and 1.01m to the left. Note that this is just the L measurement amoung the LRUD data if this was recorded with the survey data.

Negative y Values

Values along the survey leg can also be negative - this just means that the place where the perpendicular to the wall is taken from is behind you as you look along the survey leg. Similarly y values which are greater than the length of the leg are also OK - here it refers to a location beyong the extent of the leg. Both types of y values are useful when we start to bend wall shapes to follow survey legs.

Height or z values

The data points can also be in triples representing (x_i y_i z_i) values. TODO - How?

Separator Character for DATA REF

The separator between the from and to legs in the DATA REF attribute can be either one or more white spaces, a comma, semicolon or full colon. Examples REF="85,85" or REF="85 85" or REF="85;85".

Single Reference Points

XSplines

The (x_i, y_i) coordinates are sequential values which need to be joined together by a cave mapping program using splines, beziers or other means to form the cave wall on a screen or in a Postscript file.

To understand the difference between measured wall distances and fudgeable distances consider a typical cave survey where one has recorded with a tape the LRUD distances at the from and to stations. The wall shape was also draw on graph paper while in the cave. When one comes to draw up the map tape measured distances were accurate to 5cm but the wall detail from the graph paper depends on the drawing skill of the drawer.

Avens

Example Fragment of CaveMap XML Document

"Northern end of Eastern Wall" has a coordinate at (0.4 3.0) wrt 89,90 and the "Northern end of Western Wall", (-0.8 3.0) wrt 89,90

<mymap.xml avens>= (<-U)
<AVEN>
        <!-- An aven is closed by definition -->
        <DATA REF="89,90">-0.8 3.0</DATA>
        <DATA REF="90">   -0.7 0.0   -0.5 0.5   0.0 0.8   </DATA>
        <DATA REF="89,90"> 0.4 3.0</DATA>
        <DATA REF="90">    0.3 -0.3 -0.2 -0.4</DATA>
        <DATA REF="89,90">-0.8 3.0</DATA>
</AVEN>

Using X-Pointers and X-Links

The start of the North Western Wall at (-0.1 0.0) wrt 88a,88 must be linked to the start of Western Loop at (-0.4 0) wrt loop.1 (see the example survey on page [->]).

The start of North Western Wall can be given as an XPointer using the syntax: root().child(all, WALL, NAME, "Western Loop") .child(1, DATA) This selects the first DATA element within the Western Loop wall.

Similarly we can select the first DATA element in the tight loop section, west side: root().child(all, WALL, NAME, "Tight loop section, west side") .child(1, DATA)

Problems that can arise

Two situations can occur when just two walls join; an obtuse angle or an acute angle.

Obtuse Angle:
just continue the last coordinate of one wall with the first coordinate of the next wall.

Acute Angle:
if the coordinates are non-intersecting just continue the data and hence the curve otherwise, swap the coordinates.

Example Fragment of CaveMap XML Document

[*]

<mymap.xml west2>= (<-U)
<WALL NAME="Northern end of Western Wall">
        <!-- The 1st point here joins to 1st point in loop section, west side. -->
        <!-- Start from "loop.1" -->
    <DATA REF="loop.1">-0.4 0.0</DATA>
        <!-- Original data below -->
        <DATA REF="88a,88"> -0.1 0.0  -0.25 1.0  -0.5 1.5</DATA>
    <DATA REF="88,89">  -0.5 0.5  -0.5  1.0  -0.6 2.0</DATA>
    <DATA REF="89,90">  -0.5 1.0  -0.6  2.0  -0.7 2.5 -0.8 3.0</DATA>
    <XSPLINE>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</XSPLINE>
</WALL>

<mymap.xml loop>= (<-U)
<WALL NAME="Tight loop section, west side">
        <!-- The 1st point here joins with 1st point in North West Wall -->
    <DATA REF="loop.1">-0.4 0.0</DATA>
    <DATA REF="loop.2">-0.4 0.0</DATA>
    <DATA REF="loop.2,loop.3">0.5 1.5</DATA>
    <DATA REF="loop.3">-0.8 0.0</DATA>
    <DATA REF="loop.4">-0.4 0.0</DATA>
        <!-- Here is where we join it to a point on -->
        <!-- "Southern end of Western Wall" -->
    <DATA REF="85,86">-0.7 6.0</DATA>
</WALL>

<WALL NAME="Tight loop section, east side">
    <DATA REF="88,88a">-0.15 1.6</DATA>
        <!-- Original data below -->
    <DATA REF="loop.1,loop.2">-0.2 0.0   -0.2 3.3</DATA>
    <DATA REF="loop.2,loop.3">-0.2 0.2   -0.2 3.3</DATA>
    <DATA REF="loop.3,loop.4">-0.2 0.2   -0.2 2.8</DATA>
        <!-- Here is where we join it to a point on -->
        <!-- "Southern end of Western Wall" -->
    <DATA REF="85,86"> -0.8 7.0</DATA>
</WALL>

<mymap.xml west1>= (<-U)
<WALL NAME="Southern end of Western Wall">
    <DATA REF="85,86"> -1.2 0.0   -0.9 2.0   -1.0 4.0                   </DATA>
        <DATA REF="85,86" STYLE="drop"> -0.7 6.0   -0.8 7.0   -1.0 8.0  </DATA>
    <DATA REF="86">    -1.3 1.0                                 </DATA>
    <DATA REF="86,87"> -1.2 1.2   -0.8 2.0   -1.0 2.5   -0.3 3.0</DATA>
    <DATA REF="87">     0.0 0.0                                 </DATA>
    <DATA REF="87,88"> -1.0 1.0   -1.0 1.5   -1.3 2.5   -0.7 3.5</DATA>
    <DATA REF="87,88"> -0.2 5.7                                 </DATA>
    <DATA REF="88,88a">-0.2 0.7   -0.2 1.0   -0.15 1.6          </DATA>
    <XSPLINE>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</XSPLINE>
</WALL>

Special Effects

Special effects covers things such as fractal wall outlines, shadows and ``outside-wall halftoning''.

Wall Shadowing

<WALL STYLE="dotdashdot" WIDTH="2"/>

Any combination of ``dot'' and ``dash'' can be used. Can I use ``.-.-'' or ``..-..-''?

<SHADOW SUN="90"/> ie bearing of where the sun shines from.

<SHADE attrib="value"/> ie like what SSS did with the Bungonia maps

Fractal Dimension

The actual appearance of the walls drawn by the viewer could utilise a fractal dimension of say 0.43 and the random seed value of 23425 (seed value [0, 65000]).

<FRACT DIM="0.43" SEED="23425"/>

History

Information on the history of the cave pertaining to people ie not geological history. This would include say discovery date, discoverers etc.

Probably Xlink to another XML file eg. "mymap_history.xml"

<cavemap.dtd>+= [<-D]
<!ELEMENT HISTORY (#PCDATA)? >

<mymap.xml history>=
<HISTORY><A HREF="mymap_history.xml">History of MyCave</A></HISTORY>


Appendices


CaveMap DTD

CaveMap.dtd

CaveMap.dtd


Example CaveMap XML File

[*] mymap.xml

mymap.xml

Useful References

Hierarchical Tagged Objects (HTO) Portable Data Format Specification, Version 1.4, December 15, Doug Dotson 1994

Inside XML DTDs, St Laurent and Biggar, McGraw-Hill, 1999

Literate Programming Using Noweb, Linux Journal, October 97, Issue 42, p64-69

The site "http://www.pault.com/Xmltube/dtdgen.html" can generate a DTD for a supplied XML document.


Defined Chunks

[*]

The following is a list of all the code chunks defined in this document. References are interpreted as in the following example: (cavemap 32a) 32a 32b
The code chunk cavemap was defined on page 32. The a means it was the first chunk referenced on that page. The 32a and 32b are all pages which reference the chunk.

Index

This is a list of all defined variables which are declared using %def.