XML-XSLT
view release on metacpan or search on metacpan
examples/REC-xml-19980210.xml view on Meta::CPAN
appear anywhere in a document outside other
<termref def='dt-markup'>markup</termref>; in addition,
they may appear within the document type declaration
at places allowed by the grammar.
They are not part of the document's <termref def="dt-chardata">character
data</termref>; an XML
processor may, but need not, make it possible for an application to
retrieve the text of comments.
<termref def="dt-compat">For compatibility</termref>, the string
"<code>--</code>" (double-hyphen) must not occur within
comments.
<scrap lang="ebnf">
<head>Comments</head>
<prod id='NT-Comment'><lhs>Comment</lhs>
<rhs>'<!--'
((<nt def='NT-Char'>Char</nt> - '-')
| ('-' (<nt def='NT-Char'>Char</nt> - '-')))*
'-->'</rhs>
</prod>
</scrap>
</termdef></p>
<p>An example of a comment:
<eg><!&como; declarations for <head> & <body> &comc;></eg>
</p>
</div2>
<div2 id='sec-pi'>
<head>Processing Instructions</head>
<p><termdef id="dt-pi" term="Processing instruction"><term>Processing
instructions</term> (PIs) allow documents to contain instructions
for applications.
<scrap lang="ebnf">
<head>Processing Instructions</head>
<prod id='NT-PI'><lhs>PI</lhs>
<rhs>'<?' <nt def='NT-PITarget'>PITarget</nt>
(<nt def='NT-S'>S</nt>
(<nt def='NT-Char'>Char</nt>* -
(<nt def='NT-Char'>Char</nt>* &pic; <nt def='NT-Char'>Char</nt>*)))?
&pic;</rhs></prod>
<prod id='NT-PITarget'><lhs>PITarget</lhs>
<rhs><nt def='NT-Name'>Name</nt> -
(('X' | 'x') ('M' | 'm') ('L' | 'l'))</rhs>
</prod>
</scrap></termdef>
PIs are not part of the document's <termref def="dt-chardata">character
data</termref>, but must be passed through to the application. The
PI begins with a target (<nt def='NT-PITarget'>PITarget</nt>) used
to identify the application to which the instruction is directed.
The target names "<code>XML</code>", "<code>xml</code>", and so on are
reserved for standardization in this or future versions of this
specification.
The
XML <termref def='dt-notation'>Notation</termref> mechanism
may be used for
formal declaration of PI targets.
</p>
</div2>
<div2 id='sec-cdata-sect'>
<head>CDATA Sections</head>
<p><termdef id="dt-cdsection" term="CDATA Section"><term>CDATA sections</term>
may occur
anywhere character data may occur; they are
used to escape blocks of text containing characters which would
otherwise be recognized as markup. CDATA sections begin with the
string "<code><![CDATA[</code>" and end with the string
"<code>]]></code>":
<scrap lang="ebnf">
<head>CDATA Sections</head>
<prod id='NT-CDSect'><lhs>CDSect</lhs>
<rhs><nt def='NT-CDStart'>CDStart</nt>
<nt def='NT-CData'>CData</nt>
<nt def='NT-CDEnd'>CDEnd</nt></rhs></prod>
<prod id='NT-CDStart'><lhs>CDStart</lhs>
<rhs>'<![CDATA['</rhs>
</prod>
<prod id='NT-CData'><lhs>CData</lhs>
<rhs>(<nt def='NT-Char'>Char</nt>* -
(<nt def='NT-Char'>Char</nt>* ']]>' <nt def='NT-Char'>Char</nt>*))
</rhs>
</prod>
<prod id='NT-CDEnd'><lhs>CDEnd</lhs>
<rhs>']]>'</rhs>
</prod>
</scrap>
Within a CDATA section, only the <nt def='NT-CDEnd'>CDEnd</nt> string is
recognized as markup, so that left angle brackets and ampersands may occur in
their literal form; they need not (and cannot) be escaped using
"<code>&lt;</code>" and "<code>&amp;</code>". CDATA sections
cannot nest.</termdef>
</p>
<p>An example of a CDATA section, in which "<code><greeting></code>" and
"<code></greeting></code>"
are recognized as <termref def='dt-chardata'>character data</termref>, not
<termref def='dt-markup'>markup</termref>:
<eg><![CDATA[<greeting>Hello, world!</greeting>]]></eg>
</p>
</div2>
<div2 id='sec-prolog-dtd'>
<head>Prolog and Document Type Declaration</head>
<p><termdef id='dt-xmldecl' term='XML Declaration'>XML documents
may, and should,
begin with an <term>XML declaration</term> which specifies
the version of
XML being used.</termdef>
For example, the following is a complete XML document, <termref
def="dt-wellformed">well-formed</termref> but not
<termref def="dt-valid">valid</termref>:
<eg><![CDATA[<?xml version="1.0"?>
<greeting>Hello, world!</greeting>
]]></eg>
and so is this:
<eg><![CDATA[<greeting>Hello, world!</greeting>
]]></eg>
( run in 1.104 second using v1.01-cache-2.11-cpan-39bf76dae61 )