XML Overview - Teradata Meta Data Services

Teradata Meta Data Services Programmer Guide

Teradata Meta Data Services
Release Number
English (United States)
Last Update
Product Category
Teradata Tools and Utilities

XML Overview

XML lets the designer define tags, used to mark up data to indicate what the data means. Tags come in pairs – a begin tag and an end tag. Each tag is enclosed by angle brackets. End tags are named the same as their corresponding begin tags except that the end tag’s name is prefixed by a slash. The content between a matching begin and end tag is called an element. For example, an XML designer could define an address element to have a structure like

  <name>Teradata Corporation</name>
  <street>17095 Via Del Campo</street>
  <city>San Diego</city>

The designer defines the names of the tags, what each tag contains (other tags, raw character data, or a mixture), what order they appear in, whether they are required or optional, how many occurrences of each are allowed, and so on. This is basically the task of defining a grammar. XML grammars are defined using a special syntax in a file called a document type definition (DTD) that can be used by an XML parser to ensure that an XML input document conforms to the grammar.

The XML governing bodies have recently defined a “schema definition”, also known as an XSD for XML Schema Definition. A schema definition is in XML format (the DTD has its own unique format), and allows for more precise data definitions and specifications. As of the 6.1 release, MDS provides for a schema definition which is the equivalent of the DTD (which is still provided). The DTD and schema files are installed in the %METAHOME%\bin directory. The DTD is named metaxml21.dtd, and the schema is contained in two files: metaxml21.xsd and its included file types21.xsd. The use may use either, but the schema file is recommended due to its ability to more precisely describe the syntax. See the XML sample files (or any XML documentation) for examples on how to include DTD or XSD definitions in your XML file.

Like HTML tags, XML tags may have attributes. The DTD or XSD allows the designer to specify attribute names, broad data types, default values, and whether or not individual attributes are required or optional. XML attributes appear inside the tag to which they apply. An example of an XML representation of a geometric shape that uses attributes is

<circle color=”red”, 

The first attribute is color, and it has the value red. The circle representation shown is an example of an empty element, meaning there is no content between the begin and end circle tags. For convenience, XML allows the abbreviation of empty elements with the syntax

<circle color=”red”, 

(slash at the end, no separate end tag).

All tag and attribute names are case-sensitive.

The specification for XML can be found on the web at http://www.w3.org/TR/1998/REC-xml-19980210.