XML / XSL Glossary

XML Basics

This section only deals with the outlines. More detail on constructing XML documents appears elsewhere on this site. See links in the navigation bar on the left.

All XML files must either use a DTD or contain the standalone="no" attribute in the XML declaration:

<?xml version="1.0" standalone="no"?>
or
<?xml version="1.0">
<!DOCTYPE root-element SYSTEM "URL">

ALL element attributes must be enclosed in "quotation marks".

All elements must either have an opening - <ELEMENT> and a closing tag - </ELEMENT> - or be an empty tag - <ELEMENT />

All elements must be "nested" properly. Once an element is opened, all tags opened subsequently must either be empty or properly closed before the original element is closed.

<ELEMENT> contents of "ELEMENT"
<NEWELEMENT />
<OTHERELEMENT> contents of other element <OTHERELEMENT />
<!-- This comment is still within the structure of the ELEMENT tag -->
<ELEMENT />

Markup characters like & must never appear within the contents of a tag. Instead, use entity references (which are all lowercase):

&lt; for <
&gt; for >
&amp; for &
&quot; for "
and
&apos; for '

XML instructions

The XML declaration:

<?xml version="number"
[encoding="encoding"]
[standalone="yes|no"]?>

version is usually 1.0 and is a required attribute. encoding is optional and defines the character encoding for this document. standalone is optional and determines whether the document requires an external DTD.

The DOCTYPE declaration:

<!DOCTYPE root-element SYSTEM "URL of DTD">
<!DOCTYPE root-element PUBLIC "name" "URL of DTD">

Use SYSTEM for private DTD's to be applied to all contents of root-element, e.g.

<!DOCTYPE CODEHELP SYSTEM "mydtd.dtd">

Public DTD's are used for specialist XML applications like WML:

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">

CDATA declaration (character data).

<![CDATA[ . . . ]]>

The contents of CDATA elements are not expanded by the XML parser so you can include <b>non-XML tags</b> within elements. Note that the <b> tag is ignored by the XML parser. Without the CDATA element, this would cause an XML error.

<![CDATA[<b>non-XML tags</b>]]>

Comment declarations

<!-- any comment can go here, it will be ignored by the parser -->


This is part of www.codehelp.co.uk Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.