Websydian v6.1 online documentationOnline documentation - Websydian v6.1

Basic XML Terms

Introduction

This is the first document in the introduction to TransacXML.

This document introduces a number of the core terms used when describing the content of XML documents.

These terms are general terms that are not especially related to TransacXML.

The main aim of the document is to ensure that developers who have no previous experience with XML have the necessary knowledge to understand the rest of the documentation of TransacXML.

If you have any previous experience with XML, you probably already know all of these terms and what they mean - if this is the case, just skip the document.

Note that all names, namespaces etc. are case-sensitive in XML.

Tag

The tag is one of the most basic markups used in XML. They are used to create the structure of the document.

All tags start with the character < and end with the character >.

Examples: <tagname>

The XML-standard describes precise rules for the valid tag-names, but the one thing that is probably worth noting here is that a tag-name may not contain blank characters.

You can distinguish between three different types of tags:

Start-tag

A start-tag starts with the character < followed by the name of the tag followed by >.

Example: <tagname>

Start tags can contain more information (see attributes and namespace declarations below).

End-tag

An end-tag starts with the character < followed by the character / followed by the name of the tag followed by >.

Example: </tagname>

Empty-element tags

An empty-element tag starts with the character < followed by the name of the tag followed by the character / followed by >.

Element

An element starts with a start tag and ends with an end tag.

Example: <element>...</element>

The exception to this rule is that you can represent an element that has no content using an empty-element tag.

This means that <element></element> is the same as <element/>.

You can distinguish between simple elements and complex elements - this distinction is central to how you model an XML document in TransacXML.

Simple element

A simple element is an element that only contains text inside the start and end tag, and has no attributes inside the start tag.

Example: <element>value</element>

This can be understood as a name-value pair with the name: "element" and the value: "value".

Complex element

A complex element can best be understood as an element that contains a structure. This structure can be one or more child element and/or one or more attributes.

Example 1:

In this case, the complex element "complex" contains two simple child elements "first" and "second".

 

Example 2:

In this case, the complex element "top" contains another complex element "middle", which contains  two simple child elements "first" and "second".

Some examples of complex elements (Race, Course, Horses, Horse):

Attribute

An attribute has the format: name followed by an =, followed by an ", followed by the value of the attribute, followed by a ".

Example: att="value"

This can be understood as a name-value pair with the name: "att" and the value: "value".

Attributes are always placed inside the start tag of an element and the attribute is considered a child of the element.

Example: <element att="value">...</element>

Namespace declarations

XML namespaces is a mechanism for avoiding name clashes in XML documents that uses elements and attributes defined by different sources.

Namespace declarations are used to identify which namespace a set of names belongs to.

The namespace declarations have the same basic format as an attribute - and just as attributes, they are placed inside start-tags of elements.

The way you can identify them are that the name always start by xmlns. This can be followed by a : followed by a prefix.

Examples:

    xmlns=value

    xmlns:ns=value

Namespace declarations are described in more detail in a separate document. At this point, the most important thing to note is that they are not attributes.

Next document

More information

The web contains loads of documents describing XML. The following links are just a small sample of links to very basic XML descriptions.

W3C schools about XML

XMLfiles Introduction to XML

DevArticles Introduction to XML