*************************************
* *
* DB/C Newsletter *
* September 1999 *
* *
*************************************
News and Comments
DB/C FS 2.1 was recently released. It contains improvements in SQL
data type support, the ability to specify TCP/IP port numbers, and a Java
class library that allows Java programs to access files in the traditional
DATABUS fashion (sequential, random, indexed and AIM), as well as several
minor fixes.
As was noted in the April 1999 DB/C Newsletter, we believe that XML
is an important technology. This month's article provides a quick overview
of the XML language.
don.wills@swc.com
*****************************************************************************
An XML Tutorial
XML is one of the hottest buzzwords in the computer industry. In this
article, we'll give you an introduction to the basic elements of XML.
XML is an acronym for the Extensible Markup Language. XML is actually
a metalanguage. That is, it is a syntax specification only. All XML-based
languages share the same syntax.
At its basic level, XML is most useful in structuring text data.
XML can be used to structure all sorts of text including word processing
documents, data processing records, even entire data processing files.
Because XML data is structured with an exact syntax, it machine readable.
However, in its flattened, text form, XML data is also easy for a human to
read and understand.
It is probably easiest to start with an example. Here is a sample of
a purchase order in XML text format:
A56223
1999-09-30
ABC Video
100 Main Street
Ames
Iowa
55555
Bill Riley
Acme Supply
POBox 123
15 Broadway
Chicago
IL
66666
Joe
-
5
431321-2
Titanic (DVD)
-
10
744311-0
Star Wars: Episode 1 (VHS)
Here is the same XML data viewed as an upside down tree structure
(abbreviations are made to some tags and values because of limited space
and (1) and (2) are connected below):
*****************
* PurchaseOrder *
*****************
|
|
--------------------------------------------------------------------
| | | | | |
| | | | | |
******** ********************* ************ *********** ******** *********
*OrdNum* *OrdDt datetype="ISO* *Nontaxable* *Purchaser* *Vendor* *Details*
******** ********************* ************ *********** ******** *********
| | | | |
| | | | |
"A56223" "1999-09-30" | (1) (2)
|
|
-----------------------------------------------------------------
| | | | | |
| | | | | |
************ ************ ******** ******* ************ *********
* Name * * Street * * City * *State* *PostalCode* *Contact*
************ ************ ******** ******* ************ *********
| | | | | |
| | | | | |
"ABC Video" "100 Main Street" "Ames" "Iowa" "55555" "Bill Riley"
(1)
|
|
-----------------------------------------------------------------
| | | | | | |
| | | | | | |
************ ********** ********** ******** ******* ******* *********
* Name * * Street * * Street * * City * *State* *PCode* *Contact*
************ ********** ********** ******** ******* ******* *********
| | | | | | |
| | | | | | |
"Acme Supply" "POBox 123" "15 Broadway" "Chicago" "IL" "66666" "Joe"
(2)
|
|
--------------------------------------------
| |
| |
********** **********
* Item * * Item *
********** **********
| |
| |
------------------------ ------------------------
| | | | | |
| | | | | |
***** ********** ************** ***** ********** **************
*Qty* * Number * * Desc * *Qty* * Number * * Desc *
***** ********** ************** ***** ********** **************
| | | | | |
| | | | | |
"5" "431321-2" "Titanic (DVD)" "10" "744311-0" "Stars Wars.."
In its structured form, XML data can be easily manipulated with both
programs and paint-program-like visual editors.
The basic concept of XML data is an element. An element has a name.
An element optionally contains of attributes, subelements and text values.
In our example, the element named PurchaseOrder is the root element and it
contains only subelements. The element named OrderNumber contains only
a text value. The element named OrderDate contains an attribute (datetype)
and a value.
In the text form, the start tag of an element is the and
the end tag of an element is . Each start tag must be matched
with a following end tag. The terms "tag name" and "element name" are
interchangeable.
The element named Nontaxable doesn't contain anything. In the text
example it was specified with a trailing slash like this:
but it could also have been specified like this:
The first notation is preferable because it is shorter.
There may be any number of attributes contained in an element. In its
text form, an attribute is a ="value" pair that is delimited by
white space and follows the tag name in the start tag. The is
the name of the attribute. Attribute names may not be duplicated within an
element. The order of the attributes within an element is irrelevant.
The order of subelements and text values contained in an element is
relevant. Here is an example of a word processing document where there
are multiple values contained in the element named wpdoc.
The DATABUS Programming Language
Dan Felder
In this example, the element named wpdoc contains, in this order, the first
font subelement, the text value "The DATABUS Programming Language", the
second font subelement, and the text value "Dan Felder". The first font
element contains two attributes and the second font element contains one
attribute.
In its text form, there are only a few rules for an XML document to
be considered well formed. One major rule is that subelements must be
completely contained within the parent element. Here is an example of an
invalid XML document:
In text values, there are special codes to handle special characters.
The sequence "<" is used in place of "<", the sequence ">" is used in
place of ">", and the sequence "&" is used in place of "&".
What we've discussed in this article is just the basic XML elements.
XML actually contains several other non-essential but highly useful features.
The most important of these is the Document Type Definition (DTD). A DTD
specifies an actual language - that is, it specifies what element names are
allowed, what attributes are allowed, what values are allowed, what order
they must be in, and much more.
To learn more about XML, I suggest you read the book "The XML Companion"
by Neil Bradley, published by Addison-Wesley. It provides a complete and
detailed description of XML, while still being quite readable.
*****************************************************************************
DB/C Class Schedule
Class: DB/C DX and JX Language Fundamentals
Date: October 4-6, 1999
Location: Oak Brook, Illinois
For information, contact Judi Tamkevic at:
voice 630.572.0240
email dbc@swc.com
*****************************************************************************
Subscribing to the DB/C Newsletter
If you don't already have the DB/C Newsletter delivered to your email
address and would like to have it emailed to you when it is produced, just
send an email message to 'request@swc.com' and put the line 'subscribe
dbcnews' in the body of the email message (omit the ' characters). The
newsletter will be delivered to the email address from which the message
was sent. To stop delivery, put the line 'unsubscribe dbcnews' in the body
of the message.