]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/pxp/pxp/doc/manual/html/x107.html
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / doc / manual / html / x107.html
diff --git a/helm/DEVEL/pxp/pxp/doc/manual/html/x107.html b/helm/DEVEL/pxp/pxp/doc/manual/html/x107.html
new file mode 100644 (file)
index 0000000..102aba2
--- /dev/null
@@ -0,0 +1,1694 @@
+<HTML
+><HEAD
+><TITLE
+>Highlights of XML</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.46"><LINK
+REL="HOME"
+TITLE="The PXP user's guide"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="What is XML?"
+HREF="c36.html"><LINK
+REL="PREVIOUS"
+TITLE="What is XML?"
+HREF="c36.html"><LINK
+REL="NEXT"
+TITLE="A complete example: The readme DTD"
+HREF="x468.html"><LINK
+REL="STYLESHEET"
+TYPE="text/css"
+HREF="markup.css"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFFFFF"
+TEXT="#000000"
+LINK="#0000FF"
+VLINK="#840084"
+ALINK="#0000FF"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>The PXP user's guide</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="c36.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 1. What is XML?</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="x468.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="AEN107"
+>1.2. Highlights of XML</A
+></H1
+><P
+>This section explains many of the features of XML, but not all, and some
+features not in detail. For a complete description, see the <A
+HREF="http://www.w3.org/TR/1998/REC-xml-19980210.html"
+TARGET="_top"
+>XML
+specification</A
+>.</P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN111"
+>1.2.1. The DTD and the instance</A
+></H2
+><P
+>The DTD contains various declarations; in general you can only use a feature if
+you have previously declared it. The document instance file may contain the
+full DTD, but it is also possible to split the DTD into an internal and an
+external subset. A document must begin as follows if the full DTD is included:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;?xml version="1.0" encoding="<TT
+CLASS="REPLACEABLE"
+><I
+>Your encoding</I
+></TT
+>"?&gt;
+&lt;!DOCTYPE <TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+> [
+  <TT
+CLASS="REPLACEABLE"
+><I
+>Declarations</I
+></TT
+>
+]&gt;</PRE
+>
+
+These declarations are called the <I
+CLASS="EMPHASIS"
+>internal subset</I
+>. Note
+that the usage of entities and conditional sections is restricted within the
+internal subset.</P
+><P
+>If the declarations are located in a different file, you can refer to this file
+as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;?xml version="1.0" encoding="<TT
+CLASS="REPLACEABLE"
+><I
+>Your encoding</I
+></TT
+>"?&gt;
+&lt;!DOCTYPE <TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+> SYSTEM "<TT
+CLASS="REPLACEABLE"
+><I
+>file name</I
+></TT
+>"&gt;</PRE
+>
+
+The declarations in the file are called the <I
+CLASS="EMPHASIS"
+>external
+subset</I
+>. The file name is called the <I
+CLASS="EMPHASIS"
+>system
+identifier</I
+>. 
+It is also possible to refer to the file by a so-called
+<I
+CLASS="EMPHASIS"
+>public identifier</I
+>, but most XML applications won't use
+this feature.</P
+><P
+>You can also specify both internal and external subsets. In this case, the
+declarations of both subsets are mixed, and if there are conflicts, the
+declaration of the internal subset overrides those of the external subset with
+the same name. This looks as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;?xml version="1.0" encoding="<TT
+CLASS="REPLACEABLE"
+><I
+>Your encoding</I
+></TT
+>"?&gt;
+&lt;!DOCTYPE <TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+>  SYSTEM "<TT
+CLASS="REPLACEABLE"
+><I
+>file name</I
+></TT
+>" [
+  <TT
+CLASS="REPLACEABLE"
+><I
+>Declarations</I
+></TT
+>
+]&gt;</PRE
+></P
+><P
+>The XML declaration (the string beginning with <TT
+CLASS="LITERAL"
+>&lt;?xml</TT
+> and
+ending at <TT
+CLASS="LITERAL"
+>?&gt;</TT
+>) should specify the encoding of the
+file. Common values are UTF-8, and the ISO-8859 series of character sets. Note
+that every file parsed by the XML processor can begin with an XML declaration
+and that every file may have its own encoding.</P
+><P
+>The name of the root element must be mentioned directly after the
+<TT
+CLASS="LITERAL"
+>DOCTYPE</TT
+> string. This means that a full document instance
+looks like
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;?xml version="1.0" encoding="<TT
+CLASS="REPLACEABLE"
+><I
+>Your encoding</I
+></TT
+>"?&gt;
+&lt;!DOCTYPE <TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+>  SYSTEM "<TT
+CLASS="REPLACEABLE"
+><I
+>file name</I
+></TT
+>" [
+  <TT
+CLASS="REPLACEABLE"
+><I
+>Declarations</I
+></TT
+>
+]&gt;
+
+&lt;<TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+>&gt;
+  <TT
+CLASS="REPLACEABLE"
+><I
+>inner contents</I
+></TT
+>
+&lt;/<TT
+CLASS="REPLACEABLE"
+><I
+>root</I
+></TT
+>&gt;</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN146"
+>1.2.2. Reserved characters</A
+></H2
+><P
+>Some characters are generally reserved to indicate markup such that they cannot
+be used for character data. These characters are &lt;, &gt;, and
+&amp;. Furthermore, single and double quotes are sometimes reserved. If you
+want to include such a character as character, write it as follows:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>&amp;lt;</TT
+> instead of &lt;</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>&amp;gt;</TT
+> instead of &gt;</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>&amp;amp;</TT
+> instead of &amp;</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>&amp;apos;</TT
+> instead of '</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>&amp;quot;</TT
+> instead of "</P
+></LI
+></UL
+>
+
+All other characters are free in the document instance. It is possible to
+include a character by its position in the Unicode alphabet: 
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&amp;#<TT
+CLASS="REPLACEABLE"
+><I
+>n</I
+></TT
+>;</PRE
+>
+
+where <TT
+CLASS="REPLACEABLE"
+><I
+>n</I
+></TT
+> is the decimal number of the
+character. Alternatively, you can specify the character by its hexadecimal
+number: 
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&amp;#x<TT
+CLASS="REPLACEABLE"
+><I
+>n</I
+></TT
+>;</PRE
+>
+
+In the scope of declarations, the character % is no longer free. To include it
+as character, you must use the notations <TT
+CLASS="LITERAL"
+>&amp;#37;</TT
+> or
+<TT
+CLASS="LITERAL"
+>&amp;#x25;</TT
+>.</P
+><P
+>Note that besides &amp;lt;, &amp;gt;, &amp;amp;,
+&amp;apos;, and &amp;quot; there are no predefines character entities. This is
+different from HTML which defines a list of characters that can be referenced
+by name (e.g. &amp;auml; for รค); however, if you prefer named characters, you
+can declare such entities yourself (see below).</P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN173"
+>1.2.3. Elements and ELEMENT declarations</A
+></H2
+><P
+>Elements structure the document instance in a hierarchical way. There is a
+top-level element, the <I
+CLASS="EMPHASIS"
+>root element</I
+>, which contains a
+sequence of inner elements and character sections. The inner elements are
+structured in the same way. Every element has an <I
+CLASS="EMPHASIS"
+>element
+type</I
+>. The beginning of the element is indicated by a <I
+CLASS="EMPHASIS"
+>start
+tag</I
+>, written
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;<TT
+CLASS="REPLACEABLE"
+><I
+>element-type</I
+></TT
+>&gt;</PRE
+>
+
+and the element continues until the corresponding <I
+CLASS="EMPHASIS"
+>end tag</I
+>
+is reached:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;/<TT
+CLASS="REPLACEABLE"
+><I
+>element-type</I
+></TT
+>&gt;</PRE
+>
+
+In XML, it is not allowed to omit start or end tags, even if the DTD would
+permit this. Note that there are no special rules how to interpret spaces or
+newlines near start or end tags; all spaces and newlines count.</P
+><P
+>Every element type must be declared before it can be used. The declaration
+consists of two parts: the ELEMENT declaration describes the content model,
+i.e. which inner elements are allowed; the ATTLIST declaration describes the
+attributes of the element.</P
+><P
+>An element can simply allow everything as content. This is written:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ELEMENT <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> ANY&gt;</PRE
+>
+
+On the opposite, an element can be forced to be empty; declared by:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ELEMENT <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> EMPTY&gt;</PRE
+>
+
+Note that there is an abbreviated notation for empty element instances:
+<TT
+CLASS="LITERAL"
+>&lt;<TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+>/&gt;</TT
+>. </P
+><P
+>There are two more sophisticated forms of declarations: so-called
+<I
+CLASS="EMPHASIS"
+>mixed declarations</I
+>, and <I
+CLASS="EMPHASIS"
+>regular
+expressions</I
+>. An element with mixed content contains character data
+interspersed with inner elements, and the set of allowed inner elements can be
+specified. In contrast to this, a regular expression declaration does not allow
+character data, but the inner elements can be described by the more powerful
+means of regular expressions.</P
+><P
+>A declaration for mixed content looks as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ELEMENT <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> (#PCDATA | <TT
+CLASS="REPLACEABLE"
+><I
+>element<SUB
+>1</SUB
+></I
+></TT
+> | ... | <TT
+CLASS="REPLACEABLE"
+><I
+>element<SUB
+>n</SUB
+></I
+></TT
+> )*&gt;</PRE
+>
+
+or if you do not want to allow any inner element, simply
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ELEMENT <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> (#PCDATA)&gt;</PRE
+></P
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>Example</B
+></P
+><P
+>If element type <TT
+CLASS="LITERAL"
+>q</TT
+> is declared as
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ELEMENT q (#PCDATA | r | s)*&#62;</PRE
+>
+
+this is a legal instance:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;q&#62;This is character data&#60;r&#62;&#60;/r&#62;with &#60;s&#62;&#60;/s&#62;inner elements&#60;/q&#62;</PRE
+>
+
+But this is illegal because <TT
+CLASS="LITERAL"
+>t</TT
+> has not been enumerated in the
+declaration:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;q&#62;This is character data&#60;r&#62;&#60;/r&#62;with &#60;t&#62;&#60;/t&#62;inner elements&#60;/q&#62;</PRE
+></P
+></BLOCKQUOTE
+><P
+>The other form uses a regular expression to describe the possible contents:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ELEMENT <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>regexp</I
+></TT
+>&gt;</PRE
+>
+
+The following well-known regexp operators are allowed:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>element-name</I
+></TT
+></TT
+></P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>(<TT
+CLASS="REPLACEABLE"
+><I
+>subexpr<SUB
+>1</SUB
+></I
+></TT
+> ,</TT
+> ... <TT
+CLASS="LITERAL"
+>, <TT
+CLASS="REPLACEABLE"
+><I
+>subexpr<SUB
+>n</SUB
+></I
+></TT
+> )</TT
+></P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>(<TT
+CLASS="REPLACEABLE"
+><I
+>subexpr<SUB
+>1</SUB
+></I
+></TT
+> |</TT
+> ... <TT
+CLASS="LITERAL"
+>| <TT
+CLASS="REPLACEABLE"
+><I
+>subexpr<SUB
+>n</SUB
+></I
+></TT
+> )</TT
+></P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>*</TT
+></P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>+</TT
+></P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>?</TT
+></P
+></LI
+></UL
+>
+
+The <TT
+CLASS="LITERAL"
+>,</TT
+> operator indicates a sequence of sub-models, the
+<TT
+CLASS="LITERAL"
+>|</TT
+> operator describes alternative sub-models. The
+<TT
+CLASS="LITERAL"
+>*</TT
+> indicates zero or more repetitions, and
+<TT
+CLASS="LITERAL"
+>+</TT
+> one or more repetitions. Finally, <TT
+CLASS="LITERAL"
+>?</TT
+> can
+be used for optional sub-models. As atoms the regexp can contain names of
+elements; note that it is not allowed to include <TT
+CLASS="LITERAL"
+>#PCDATA</TT
+>.</P
+><P
+>The exact syntax of the regular expressions is rather strange. This can be
+explained best by a list of constraints:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+>The outermost expression must not be
+<TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>element-name</I
+></TT
+></TT
+>. </P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+> 
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x y&#62;</TT
+>; this must be written as
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x (y)&#62;</TT
+>.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>For the unary operators <TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>*</TT
+>,
+<TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>+</TT
+>, and
+<TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+>?</TT
+>, the
+<TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>subexpr</I
+></TT
+></TT
+> must not be again an
+unary operator.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+> 
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x y**&#62;</TT
+>; this must be written as
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x (y*)*&#62;</TT
+>.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>Between <TT
+CLASS="LITERAL"
+>)</TT
+> and one of the unary operatory
+<TT
+CLASS="LITERAL"
+>*</TT
+>, <TT
+CLASS="LITERAL"
+>+</TT
+>, or <TT
+CLASS="LITERAL"
+>?</TT
+>, there must
+not be whitespace.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+> 
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x (y|z) *&#62;</TT
+>; this must be written as
+<TT
+CLASS="LITERAL"
+>&#60;!ELEMENT x (y|z)*&#62;</TT
+>.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>There is the additional constraint that the
+right parenthsis must be contained in the same entity as the left parenthesis;
+see the section about parsed entities below.</P
+></LI
+></UL
+>&#13;</P
+><P
+>Note that there is another restriction on regular expressions which must be
+deterministic. This means that the parser must be able to see by looking at the
+next token which alternative is actually used, or whether the repetition
+stops. The reason for this is simply compatability with SGML (there is no
+intrinsic reason for this rule; XML can live without this restriction).</P
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>Example</B
+></P
+><P
+>The elements are declared as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ELEMENT q (r?, (s | t)+)&#62;
+&#60;!ELEMENT r (#PCDATA)&#62;
+&#60;!ELEMENT s EMPTY&#62;
+&#60;!ELEMENT t (q | r)&#62;</PRE
+>
+
+This is a legal instance:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;q&#62;&#60;r&#62;Some characters&#60;/r&#62;&#60;s/&#62;&#60;/q&#62;</PRE
+>
+
+(Note: <TT
+CLASS="LITERAL"
+>&lt;s/&gt;</TT
+> is an abbreviation for
+<TT
+CLASS="LITERAL"
+>&lt;s&gt;&lt;/s&gt;</TT
+>.)
+
+It would be illegal to leave <TT
+CLASS="LITERAL"
+>&#60;s/&#62;</TT
+> out because at
+least one instance of <TT
+CLASS="LITERAL"
+>s</TT
+> or <TT
+CLASS="LITERAL"
+>t</TT
+> must be
+present. It would be illegal, too, if characters existed outside the
+<TT
+CLASS="LITERAL"
+>r</TT
+> element; the only exception is white space. -- This is
+legal, too:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;q&#62;&#60;s/&#62;&#60;t&#62;&#60;q&#62;&#60;s/&#62;&#60;/q&#62;&#60;/t&#62;&#60;/q&#62;</PRE
+></P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN304"
+>1.2.4. Attribute lists and ATTLIST declarations</A
+></H2
+><P
+>Elements may have attributes. These are put into the start tag of an element as
+follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;<TT
+CLASS="REPLACEABLE"
+><I
+>element-name</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>attribute<SUB
+>1</SUB
+></I
+></TT
+>="<TT
+CLASS="REPLACEABLE"
+><I
+>value<SUB
+>1</SUB
+></I
+></TT
+>" ... <TT
+CLASS="REPLACEABLE"
+><I
+>attribute<SUB
+>n</SUB
+></I
+></TT
+>="<TT
+CLASS="REPLACEABLE"
+><I
+>value<SUB
+>n</SUB
+></I
+></TT
+>"&gt;</PRE
+>
+
+Instead of
+<TT
+CLASS="LITERAL"
+>"<TT
+CLASS="REPLACEABLE"
+><I
+>value<SUB
+>k</SUB
+></I
+></TT
+>"</TT
+>
+it is also possible to use single quotes as in
+<TT
+CLASS="LITERAL"
+>'<TT
+CLASS="REPLACEABLE"
+><I
+>value<SUB
+>k</SUB
+></I
+></TT
+>'</TT
+>.
+Note that you cannot use double quotes literally within the value of the
+attribute if double quotes are the delimiters; the same applies to single
+quotes. You can generally not use &lt; and &amp; as characters in attribute
+values. It is possible to include the paraphrases &amp;lt;, &amp;gt;,
+&amp;amp;, &amp;apos;, and &amp;quot; (and any other reference to a general
+entity as long as the entity is not defined by an external file) as well as
+&amp;#<TT
+CLASS="REPLACEABLE"
+><I
+>n</I
+></TT
+>;.</P
+><P
+>Before you can use an attribute you must declare it. An ATTLIST declaration
+looks as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ATTLIST <TT
+CLASS="REPLACEABLE"
+><I
+>element-name</I
+></TT
+> 
+          <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-name</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-type</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-default</I
+></TT
+>
+          ...
+          <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-name</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-type</I
+></TT
+> <TT
+CLASS="REPLACEABLE"
+><I
+>attribute-default</I
+></TT
+>
+&gt;</PRE
+>
+
+There are a lot of types, but most important are:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>CDATA</TT
+>: Every string is allowed as attribute value.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>NMTOKEN</TT
+>: Every nametoken is allowed as attribute
+value. Nametokens consist (mainly) of letters, digits, ., :, -, _ in arbitrary
+order.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>NMTOKENS</TT
+>: A space-separated list of nametokens is allowed as
+attribute value.</P
+></LI
+></UL
+>
+
+The most interesting default declarations are:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>#REQUIRED</TT
+>: The attribute must be specified.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>#IMPLIED</TT
+>: The attribute can be specified but also can be
+left out. The application can find out whether the attribute was present or
+not. </P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+><TT
+CLASS="LITERAL"
+>"<TT
+CLASS="REPLACEABLE"
+><I
+>value</I
+></TT
+>"</TT
+> or
+<TT
+CLASS="LITERAL"
+>'<TT
+CLASS="REPLACEABLE"
+><I
+>value</I
+></TT
+>'</TT
+>: This particular value is
+used as default if the attribute is omitted in the element.</P
+></LI
+></UL
+></P
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>Example</B
+></P
+><P
+>This is a valid attribute declaration for element type <TT
+CLASS="LITERAL"
+>r</TT
+>:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ATTLIST r 
+          x CDATA    #REQUIRED
+          y NMTOKEN  #IMPLIED
+          z NMTOKENS "one two three"&#62;</PRE
+>
+
+This means that <TT
+CLASS="LITERAL"
+>x</TT
+> is a required attribute that cannot be
+left out, while <TT
+CLASS="LITERAL"
+>y</TT
+> and <TT
+CLASS="LITERAL"
+>z</TT
+> are optional. The
+XML parser indicates the application whether <TT
+CLASS="LITERAL"
+>y</TT
+> is present or
+not, but if <TT
+CLASS="LITERAL"
+>z</TT
+> is missing the default value
+"one two three" is returned automatically. </P
+><P
+>This is a valid example of these attributes:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;r x="He said: &#38;quot;I don't like quotes!&#38;quot;" y='1'&#62;</PRE
+></P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN368"
+>1.2.5. Parsed entities</A
+></H2
+><P
+>Elements describe the logical structure of the document, while
+<I
+CLASS="EMPHASIS"
+>entities</I
+> determine the physical structure. Entities are
+the pieces of text the parser operates on, mostly files and macros. Entities
+may be <I
+CLASS="EMPHASIS"
+>parsed</I
+> in which case the parser reads the text and
+interprets it as XML markup, or <I
+CLASS="EMPHASIS"
+>unparsed</I
+> which simply
+means that the data of the entity has a foreign format (e.g. a GIF icon).</P
+><P
+>If the parsed entity is going to be used as part of the DTD, it
+is called a <I
+CLASS="EMPHASIS"
+>parameter entity</I
+>. You can declare a parameter
+entity with a fixed text as content by:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ENTITY % <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> "<TT
+CLASS="REPLACEABLE"
+><I
+>value</I
+></TT
+>"&gt;</PRE
+>
+
+Within the DTD, you can <I
+CLASS="EMPHASIS"
+>refer to</I
+> this entity, i.e. read
+the text of the entity, by:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>%<TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+>;</PRE
+>
+
+Such entities behave like macros, i.e. when they are referred to, the
+macro text is inserted and read instead of the original text.
+
+<BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>Example</B
+></P
+><P
+>For example, you can declare two elements with the same content model by:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % model "a | b | c"&#62;
+&#60;!ELEMENT x (%model;)&#62;
+&#60;!ELEMENT y (%model;)&#62;</PRE
+>&#13;</P
+></BLOCKQUOTE
+>
+
+If the contents of the entity are given as string constant, the entity is
+called an <I
+CLASS="EMPHASIS"
+>internal</I
+> entity. It is also possible to name a
+file to be used as content (an <I
+CLASS="EMPHASIS"
+>external</I
+> entity):
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ENTITY % <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> SYSTEM "<TT
+CLASS="REPLACEABLE"
+><I
+>file name</I
+></TT
+>"&gt;</PRE
+>
+
+There are some restrictions for parameter entities:
+
+<P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+STYLE="list-style-type: disc"
+><P
+>If the internal parameter entity contains the first token of a declaration
+(i.e. <TT
+CLASS="LITERAL"
+>&lt;!</TT
+>), it must also contain the last token of the
+declaration, i.e. the <TT
+CLASS="LITERAL"
+>&gt;</TT
+>. This means that the entity
+either contains a whole number of complete declarations, or some text from the
+middle of one declaration.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+>
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % e "(a | b | c)&#62;"&#62;
+&#60;!ELEMENT x %e;</PRE
+> Because <TT
+CLASS="LITERAL"
+>&lt;!</TT
+> is contained in the main
+entity, and the corresponding <TT
+CLASS="LITERAL"
+>&gt;</TT
+> is contained in the
+entity <TT
+CLASS="LITERAL"
+>e</TT
+>.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>If the internal parameter entity contains a left paranthesis, it must also
+contain the corresponding right paranthesis.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+>
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % e "(a | b | c"&#62;
+&#60;!ELEMENT x %e;)&#62;</PRE
+> Because <TT
+CLASS="LITERAL"
+>(</TT
+> is contained in the entity 
+<TT
+CLASS="LITERAL"
+>e</TT
+>, and the corresponding <TT
+CLASS="LITERAL"
+>)</TT
+> is
+contained in the main entity.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>When reading text from an entity, the parser automatically inserts one space
+character before the entity text and one space character after the entity
+text. However, this rule is not applied within the definition of another
+entity.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Legal:</I
+>
+<PRE
+CLASS="PROGRAMLISTING"
+> 
+&#60;!ENTITY % suffix "gif"&#62; 
+&#60;!ENTITY iconfile 'icon.%suffix;'&#62;</PRE
+> Because <TT
+CLASS="LITERAL"
+>%suffix;</TT
+> is referenced within
+the definition text for <TT
+CLASS="LITERAL"
+>iconfile</TT
+>, no additional spaces are
+added.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+>
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % suffix "test"&#62;
+&#60;!ELEMENT x.%suffix; ANY&#62;</PRE
+>
+Because <TT
+CLASS="LITERAL"
+>%suffix;</TT
+> is referenced outside the definition
+text of another entity, the parser replaces <TT
+CLASS="LITERAL"
+>%suffix;</TT
+> by
+<TT
+CLASS="LITERAL"
+><TT
+CLASS="REPLACEABLE"
+><I
+>space</I
+></TT
+>test<TT
+CLASS="REPLACEABLE"
+><I
+>space</I
+></TT
+></TT
+>. </P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+>
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % e "(a | b | c)"&#62;
+&#60;!ELEMENT x %e;*&#62;</PRE
+> Because there is a whitespace between <TT
+CLASS="LITERAL"
+>)</TT
+>
+and <TT
+CLASS="LITERAL"
+>*</TT
+>, which is illegal.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>An external parameter entity must always consist of a whole number of complete
+declarations.</P
+></LI
+><LI
+STYLE="list-style-type: disc"
+><P
+>In the internal subset of the DTD, a reference to a parameter entity (internal
+or external) is only allowed at positions where a new declaration can start.</P
+></LI
+></UL
+></P
+><P
+>If the parsed entity is going to be used in the document instance, it is called
+a <I
+CLASS="EMPHASIS"
+>general entity</I
+>. Such entities can be used as
+abbreviations for frequent phrases, or to include external files. Internal
+general entities are declared as follows:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ENTITY <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> "<TT
+CLASS="REPLACEABLE"
+><I
+>value</I
+></TT
+>"&gt;</PRE
+>
+
+External general entities are declared this way:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&lt;!ENTITY <TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+> SYSTEM "<TT
+CLASS="REPLACEABLE"
+><I
+>file name</I
+></TT
+>"&gt;</PRE
+>
+
+References to general entities are written as:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#38;<TT
+CLASS="REPLACEABLE"
+><I
+>name</I
+></TT
+>;</PRE
+>
+
+The main difference between parameter and general entities is that the former
+are only recognized in the DTD and that the latter are only recognized in the
+document instance. As the DTD is parsed before the document, the parameter
+entities are expanded first; for example it is possible to use the content of a
+parameter entity as the name of a general entity:
+<TT
+CLASS="LITERAL"
+>&amp;#38;%name;;</TT
+><A
+NAME="AEN445"
+HREF="#FTN.AEN445"
+>[1]</A
+>.</P
+><P
+>General entities must respect the element hierarchy. This means that there must
+be an end tag for every start tag in the entity value, and that end tags
+without corresponding start tags are not allowed.</P
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>Example</B
+></P
+><P
+>If the author of a document changes sometimes, it is worthwhile to set up a
+general entity containing the names of the authors. If the author changes, you
+need only to change the definition of the entity, and do not need to check all
+occurrences of authors' names:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY authors "Gerd Stolpmann"&#62;</PRE
+>
+
+In the document text, you can now refer to the author names by writing
+<TT
+CLASS="LITERAL"
+>&amp;authors;</TT
+>.</P
+><P
+><I
+CLASS="EMPHASIS"
+>Illegal:</I
+>
+The following two entities are illegal because the elements in the definition
+do not nest properly:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY lengthy-tag "&#60;section textcolor='white' background='graphic'&#62;"&#62;
+&#60;!ENTITY nonsense    "&#60;a&#62;&#60;/b&#62;"&#62;</PRE
+></P
+></BLOCKQUOTE
+><P
+>Earlier in this introduction we explained that there are substitutes for
+reserved characters: &amp;lt;, &amp;gt;, &amp;amp;, &amp;apos;, and
+&amp;quot;. These are simply predefined general entities; note that they are
+the only predefined entities. It is allowed to define these entities again
+as long as the meaning is unchanged.</P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN463"
+>1.2.6. Notations and unparsed entities</A
+></H2
+><P
+>Unparsed entities have a foreign format and can thus not be read by the XML
+parser. Unparsed entities are always external. The format of an unparsed entity
+must have been declared, such a format is called a
+<I
+CLASS="EMPHASIS"
+>notation</I
+>. The entity can then be declared by referring to
+this notation. As unparsed entities do not contain XML text, it is not possible
+to include them directly into the document; you can only declare attributes
+such that names of unparsed entities are acceptable values.</P
+><P
+>As you can see, unparsed entities are too complicated in order to have any
+purpose. It is almost always better to simply pass the name of the data file as
+normal attribute value, and let the application recognize and process the
+foreign format. </P
+></DIV
+></DIV
+><H3
+CLASS="FOOTNOTES"
+>Notes</H3
+><TABLE
+BORDER="0"
+CLASS="FOOTNOTES"
+WIDTH="100%"
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+WIDTH="5%"
+><A
+NAME="FTN.AEN445"
+HREF="x107.html#AEN445"
+>[1]</A
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+WIDTH="95%"
+><P
+>This construct is only
+allowed within the definition of another entity; otherwise extra spaces would
+be added (as explained above). Such indirection is not recommended.</P
+><P
+>Complete example:
+<PRE
+CLASS="PROGRAMLISTING"
+>&#60;!ENTITY % variant "a"&#62;      &#60;!-- or "b" --&#62;
+&#60;!ENTITY text-a "This is text A."&#62;
+&#60;!ENTITY text-b "This is text B."&#62;
+&#60;!ENTITY text "&#38;#38;text-%variant;;"&#62;</PRE
+>
+You can now write <TT
+CLASS="LITERAL"
+>&amp;text;</TT
+> in the document instance, and
+depending on the value of <TT
+CLASS="LITERAL"
+>variant</TT
+> either
+<TT
+CLASS="LITERAL"
+>text-a</TT
+> or <TT
+CLASS="LITERAL"
+>text-b</TT
+> is inserted.</P
+></TD
+></TR
+></TABLE
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="c36.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="x468.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>What is XML?</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="c36.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>A complete example: The <I
+CLASS="EMPHASIS"
+>readme</I
+> DTD</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file