| 1 |
<chapter id="ch-gssgml"> |
| 2 |
<?dbhtml filename="ch01.html"?> |
| 3 |
<chapterinfo> |
| 4 |
<pubdate>$Date$</pubdate> |
| 5 |
<releaseinfo>$Revision$</releaseinfo> |
| 6 |
</chapterinfo> |
| 7 |
<title>Знакомство<?lb?>с &SGML;/&XML;</title> |
| 8 |
<para> |
| 9 |
<indexterm id="getstartSGML" class="startofrange"><primary>SGML</primary> |
| 10 |
<secondary>начало</secondary></indexterm> |
| 11 |
<indexterm id="XMLgetstart" class="startofrange"><primary>XML</primary> |
| 12 |
<secondary>начало</secondary></indexterm> |
| 13 |
|
| 14 |
В этой главе даётся краткое введение в структурированную разметку (&SGML; и &XML;). Если вы уже знакомы с &SGML; или &XML;, можете пропустить эту главу.</para> |
| 15 |
<para> |
| 16 |
Для работы с DocBook нужно понять основную концепцию (структурных) языков разметки. Она описана ниже в этой главе. О структуре документов DocBook написано в следующей главе.</para> |
| 17 |
<sect1 id="ch01-compare"> |
| 18 |
<title>&HTML; и &SGML; vs. &XML;</title> |
| 19 |
<para> |
| 20 |
<indexterm><primary>HTML</primary> |
| 21 |
<secondary>XML vs.</secondary></indexterm> |
| 22 |
<indexterm><primary>Hypertext Markup Language</primary><see>HTML</see></indexterm> |
| 23 |
<indexterm><primary>SGML</primary> |
| 24 |
<secondary>HTML vs.</secondary></indexterm> |
| 25 |
|
| 26 |
Здесь не предполается, что вы знакомы с &HTML;, но если это так (вы знакомы), вам будет легче разобраться в языках разметки вообще. &HTML; (HyperText Markup Language) - это способ разметки текста и графики, который могут интерпретировать web-обозреватели. &HTML; состоит из набора разметочных тегов, каждый из которых изменяет отображене заключённого в него текста. Более того, &HTML; является упрощённой модификацией &SGML;. Но его простота есть одновременно его и сильная и слабая сторона. Из-за ограничений &HTML;, его расширяли всеми возможными и невозможными путями (естественно отходя от стандартов и спецификаций, которые, впрочем, тоже выпускались один за другим ), при чём каждый обозреватель делал это по разному, что вынуждало добросовестных web-мастеров устанавливать несколько обозревателей, или даже перезагружаться в другую ОС для тестирования сайта в IE. |
| 27 |
</para> |
| 28 |
<para> |
| 29 |
|
| 30 |
|
| 31 |
&SGML; - международный стандарт, описывающий как нужно определять языки разметки. &SGML; не имеет каких-либо собственных тегов или правил их использования. &HTML; - пример языка разметки, определённого в &SGML;.</para> |
| 32 |
<para> |
| 33 |
<indexterm><primary>XML</primary> |
| 34 |
<secondary>HTML и SGML vs.</secondary></indexterm> |
| 35 |
|
| 36 |
&XML; был разработан недавно и большинство обозревателей уже совместимы с ним. &XML; - это не новый язык разметки, соревнующийся с &HTML;, и он не был создан для добавления головной боли (преобразованием) людям с тоннами документов &HTML;. &XML; призван устанить проблемы совместимости с различными обозревателями, это новая, более простая версия стандартнов управления разметкой, или, другими словами, новая версия &SGML;. Правила &XML; созданaны таким образом, чтобы упростить написание как программ, которые интерпретируют его тип разметки, так и программ, генерирующих разметку. &XML; разработан командой специалистов по &SGML;, понимающих и стремящихся устранить трудности изучения и реализации &SGML;. &XML; - это т.н. <emphasis>расширяемый</emphasis> (<emphasis>extensible</emphasis>) язык разметки, что означает, то его можно легко подстроить под свои нужды. Обозреватель или текстовый процессор, совместимый с &XML; сможет читать любой язык разметки (возможно созданный самим пользователем), основывающийся на &XML;.</para> |
| 37 |
<para> |
| 38 |
В местах, где будут различия между реализациями для &SGML; и &XML; (их немного), будут стоять соответствующие примечания. На самом деле, не очень важно, используете ли вы &SGML; или &XML;.</para> |
| 39 |
<para> |
| 40 |
Т.к. &XML; поддерживается всеми популярными обозревателями, а также разнообразными программами по его преобразованию в различные форматы.</para> |
| 41 |
</sect1> |
| 42 |
<sect1 id="s1-basic-concepts"> |
| 43 |
<title>Основные понятия &SGML;/&XML;</title> |
| 44 |
<para> |
| 45 |
<indexterm id="SGMLbasicconceptch01" class="startofrange"><primary>SGML</primary> |
| 46 |
<secondary>понятия</secondary></indexterm> |
| 47 |
<indexterm id="XMLbasicconceptch01" class="startofrange"><primary>XML</primary> |
| 48 |
<secondary>понятия</secondary></indexterm> |
| 49 |
|
| 50 |
<indexterm><primary>XML</primary> |
| 51 |
<secondary>понятия</secondary></indexterm> |
| 52 |
<indexterm><primary>структурированный семантический язык разметки</primary><see>SGML</see></indexterm> |
| 53 |
|
| 54 |
Основные понятия &SGML;/&XML; в сжатом виде: |
| 55 |
</para> |
| 56 |
<itemizedlist> |
| 57 |
<listitem><para>структурированная, семантическая разметка</para> |
| 58 |
</listitem> |
| 59 |
<listitem><para>элементы</para> |
| 60 |
</listitem> |
| 61 |
<listitem><para>атрибуты</para> |
| 62 |
</listitem> |
| 63 |
<listitem><para>объекты (entities)</para> |
| 64 |
</listitem> |
| 65 |
</itemizedlist> |
| 66 |
<sect2> |
| 67 |
<title>Структурированный и семантический язык разметки</title> |
| 68 |
<para> |
| 69 |
<indexterm><primary>внешний вид</primary> |
| 70 |
<secondary>SGML и</secondary></indexterm> |
| 71 |
<indexterm><primary>структурированная разметка</primary></indexterm> |
| 72 |
<indexterm><primary>семантическая разметка</primary></indexterm> |
| 73 |
Основное отличие структурированной разметки - это его строгость отделения (а затем соответствующая разметка документа) структурной и смысловой (семантической) информации документа. Он сам по себе не устанавливает способ отображения документа, как для печати, так и в электронном виде. |
| 74 |
</para> |
| 75 |
<para> |
| 76 |
До появления т.н. текстовых процессоров, рукописи книг передавались издательству напечатанные на машинке. Такие документы определяли логическую структуру (т.е. разделяли главы, разделы и т.д.), над выбором оформления уже работали дизайнеры, а затем текст отдавали в набор, где его размечали в выбранном дизайнером формате.</para> |
| 77 |
<para> |
| 78 |
<indexterm><primary>представление</primary><see>внешний вид</see></indexterm> |
| 79 |
<indexterm><primary>HTML</primary> |
| 80 |
<secondary>внешний вид, ограничения спецификации</secondary></indexterm> |
| 81 |
|
| 82 |
Т.к. представление или внешний вид обычно основываются на структуре и содержании, разметка &SGML; логически предшествует и в общем определяет как документ будет выглядеть для конечного читателя. If you are familiar with strict, simple &HTML; markup, you know that a given document that is structurally the same can also look different on different computers. That's because the markup does not specify many aspects of a document's appearance, although it does specify many aspects of a document's structure.</para> |
| 83 |
<para> |
| 84 |
<indexterm><primary>текст</primary> |
| 85 |
<secondary>форматирование</secondary></indexterm> |
| 86 |
<indexterm><primary>текстовые процессоры, SGML/XML vs.</primary></indexterm> |
| 87 |
Многие писатели набирают текст в текстовом процессоре, строку за строкой, слово за словом, выделяя курсивом технические термины, подчёркивая слова для выделения их, или установкой цвета заголовков разделов, сочетающегося с остальным текстом, и, наконец, наглядным их отделением с помощью нескольких переводом каретки. The format such a writer imposes on the words on the screen imparts structure to the document by changing its appearance in ways that a reader can more or less reliably decode. The reliability depends on how consistently and unambiguously the changes in type and layout are made. By contrast, an &SGML;/&XML; markup of a section header explicitly specifies that a specific piece of text is a section header. This assertion does not specify the presentation or appearance of the section header, but it makes the fact that the text is a section header completely unambiguous.</para> |
| 88 |
<para> |
| 89 |
<indexterm><primary>элементы</primary> |
| 90 |
<secondary>SGML/XML, использовнаие</secondary></indexterm> |
| 91 |
<indexterm><primary>заголовки</primary> |
| 92 |
<secondary>разделы верхнего уровня</secondary></indexterm> |
| 93 |
<indexterm><primary>разделы верхнего уровня</primary></indexterm> |
| 94 |
<indexterm><primary>символы</primary> |
| 95 |
<secondary>кодировки</secondary> |
| 96 |
<tertiary>документы SGML</tertiary></indexterm> |
| 97 |
<indexterm><primary>кодировка ASCII</primary></indexterm> |
| 98 |
<indexterm><primary>XML</primary> |
| 99 |
<secondary>кодировка Unicode</secondary></indexterm> |
| 100 |
<indexterm><primary>кодировка Unicode</primary> |
| 101 |
<secondary>документы XML, использование</secondary></indexterm> |
| 102 |
|
| 103 |
&SGML; и &XML; используют элементы, заключённые в знаки меньше и больше (“<” и “>”) для описания самой разметки. В DocBook, самым верхним разделом является <sgmltag class="starttag">sect1</sgmltag>, так что заголовок раздела первого уровня <emphasis>My First-Level Header</emphasis> будет выглядеть так:</para> |
| 104 |
|
| 105 |
<screen><sect1><title>My First-Level Header</title> </screen> |
| 106 |
|
| 107 |
<para>Заметьте следующие возможности такой разметки:</para> |
| 108 |
<variablelist> |
| 109 |
<varlistentry> |
| 110 |
<term>Прозрачность</term> |
| 111 |
<listitem><para>Заголовок начинается с <sgmltag class="starttag"> title</sgmltag> и заканчивается <sgmltag class="endtag">title</sgmltag>. Тег <sgmltag>sect1</sgmltag> также имеет закрывающую часть <sgmltag class="endtag">sect1</sgmltag>, но мы показали лишь отрывок, в который она не вошла.</para> |
| 112 |
</listitem> |
| 113 |
</varlistentry> |
| 114 |
<varlistentry> |
| 115 |
<term>Иерархия</term> |
| 116 |
<listitem><para>“My First-Level |
| 117 |
“My First-Level Header” - это заголовок раздела первого уровня т.к. он расположен внутри <sgmltag>sect1</sgmltag>. Элемент <sgmltag>title</sgmltag>, может встречаться и в других местах, например внутри <sgmltag>Chapter</sgmltag> он определяет заголовок главы.</para> |
| 118 |
</listitem> |
| 119 |
</varlistentry> |
| 120 |
<varlistentry> |
| 121 |
<term>Обычный текст</term> |
| 122 |
<listitem><para>&SGML; документы могут содержать различные кодировки, по умолчанию - это <acronym>ASCII</acronym>. Документы &XML; используют кодировку Unicode (которая, кстати, содержит также кириллицу, в т.ч. и украинские символы). Это делает их легко переносимыми на различные платформы.</para> |
| 123 |
</listitem> |
| 124 |
</varlistentry> |
| 125 |
</variablelist> |
| 126 |
<para> |
| 127 |
<indexterm><primary>внешний вид</primary> |
| 128 |
<secondary>SGML и</secondary></indexterm> |
| 129 |
<indexterm><primary>форматирование</primary> |
| 130 |
<secondary>SGML документы</secondary></indexterm> |
| 131 |
<indexterm><primary>имена файлов</primary> |
| 132 |
<secondary>теги, указание</secondary></indexterm> |
| 133 |
<indexterm><primary>смысловое содержание, разметка SGML</primary></indexterm> |
| 134 |
|
| 135 |
In an &SGML; document, there is no obligatory difference between the |
| 136 |
size or face of the type in a first-level section header and the title |
| 137 |
of a book in a footnote or the first sentence of a body paragraph. All |
| 138 |
&SGML; files are simple text files without font changes or special |
| 139 |
characters.<footnote><para>Some structured editors apply style to the |
| 140 |
document while it's being edited, using fonts and color to make the |
| 141 |
editing task easier, but this stylistic information is not stored in |
| 142 |
the actual &SGML;/&XML; document. Instead, it is provided by the |
| 143 |
editing application.</para></footnote> Similarly, an &SGML; document |
| 144 |
does not specify the words in a text that are to be set in italic, |
| 145 |
bold, or roman type. Instead, &SGML; marks certain kinds of texts for |
| 146 |
their semantic content. For example, if a particular word is the name |
| 147 |
of a file, then the tags around it should specify that it is a |
| 148 |
filename: |
| 149 |
</para> |
| 150 |
|
| 151 |
<screen>Many mail programs read configuration information from the |
| 152 |
users <sgmltag class="starttag">filename</sgmltag>.mailrc<sgmltag class="endtag">filename</sgmltag> file.</screen> |
| 153 |
|
| 154 |
<para> |
| 155 |
<indexterm><primary><primary>таблицы стилей</primary></primary> |
| 156 |
<secondary>документы SGML, определения форматирования</secondary></indexterm> |
| 157 |
<indexterm><primary>внешний вид</primary> |
| 158 |
<secondary>структура или содержание vs.</secondary></indexterm> |
| 159 |
<indexterm><primary>CSS</primary></indexterm> |
| 160 |
<indexterm><primary>FOSI</primary></indexterm> |
| 161 |
<indexterm><primary>DSSSL</primary></indexterm> |
| 162 |
<indexterm><primary>XSL</primary></indexterm> |
| 163 |
<indexterm><primary>XML</primary> |
| 164 |
<secondary>XSL</secondary></indexterm> |
| 165 |
|
| 166 |
If the meaning of a phrase is particularly audacious, it might get |
| 167 |
tagged for boldness of thought instead of appearance. An &SGML; |
| 168 |
document contains all the information that a typesetter needs to lay |
| 169 |
out and typeset a printed page in the most effective and consistent |
| 170 |
way, but it does not specify the layout or the |
| 171 |
type.<footnote><para>The distinction between appearance or |
| 172 |
presentation and structure or content is essential to &SGML;, but |
| 173 |
there is a way to specify the appearance of an &SGML; document: attach |
| 174 |
a stylesheet to it. There are several standards for such stylesheets: |
| 175 |
<acronym>CSS</acronym>, <acronym>XSL</acronym>, <acronym>FOSI</acronym>s, |
| 176 |
and <acronym>DSSSL</acronym>. |
| 177 |
See <xref linkend="ch-publish"/>.</para></footnote> |
| 178 |
</para> |
| 179 |
<para> |
| 180 |
<indexterm><primary>DocBook DTD</primary> |
| 181 |
<secondary>document type definition</secondary></indexterm> |
| 182 |
<indexterm><primary>declarations</primary> |
| 183 |
<secondary>SGML documents</secondary></indexterm> |
| 184 |
<indexterm><primary>document type definitions</primary><see>DTDs</see></indexterm> |
| 185 |
<indexterm><primary>tags</primary> |
| 186 |
<secondary>names</secondary> |
| 187 |
<tertiary>document type definition</tertiary></indexterm> |
| 188 |
<indexterm><primary>combination rules (DTD)</primary></indexterm> |
| 189 |
<indexterm><primary>DTDs</primary></indexterm> |
| 190 |
<indexterm><primary>DTDs</primary> |
| 191 |
<secondary>DocBook</secondary><see>DocBook DTD</see></indexterm> |
| 192 |
|
| 193 |
|
| 194 |
Not only is the structure of an &SGML;/&XML; document explicit, but it |
| 195 |
is also carefully controlled. An &SGML; document makes reference to a |
| 196 |
set of declarations—a document type definition |
| 197 |
(&DTD;)—that contains an inventory of tag names and specifies |
| 198 |
the combination rules for the various structural and semantic features |
| 199 |
that make up a document. What the distinctive features are and how |
| 200 |
they should be combined is “arbitrary” in the sense that |
| 201 |
almost any selection of features and rules of composition is |
| 202 |
theoretically possible. The DocBook &DTD; chooses a particular set of |
| 203 |
features and rules for its users. |
| 204 |
</para> |
| 205 |
<para> |
| 206 |
<indexterm><primary>sections</primary> |
| 207 |
<secondary>ordering, DocBook DTD rules (example)</secondary></indexterm> |
| 208 |
Here is a specific example of how the DocBook &DTD; works. DocBook |
| 209 |
specifies that a third-level section can follow a second-level section |
| 210 |
but cannot follow a first-level section without an intervening |
| 211 |
second-level section. |
| 212 |
</para> |
| 213 |
<informaltable> |
| 214 |
<tgroup cols="2"> |
| 215 |
<colspec colname="COLSPEC0" colwidth="2.50in"/> |
| 216 |
<colspec colname="COLSPEC1" colwidth="2.50in"/> |
| 217 |
<tbody> |
| 218 |
<row> |
| 219 |
<entry colname="COLSPEC0" valign="top"><para>This is valid:</para><screen><sect1><title>...</title> |
| 220 |
<sect2><title>...</title> |
| 221 |
<sect3><title>...</title> |
| 222 |
... |
| 223 |
</sect3> |
| 224 |
</sect2> |
| 225 |
</sect1> |
| 226 |
</screen></entry> |
| 227 |
<entry colname="COLSPEC1" valign="top"><para>This is not:</para><screen><sect1><title>...</title> |
| 228 |
<sect3><title>...</title> |
| 229 |
... |
| 230 |
</sect3> |
| 231 |
</sect1> |
| 232 |
</screen></entry> |
| 233 |
</row> |
| 234 |
</tbody> |
| 235 |
</tgroup> |
| 236 |
</informaltable> |
| 237 |
<para> |
| 238 |
<indexterm><primary>parsers</primary> |
| 239 |
<secondary>validating</secondary></indexterm> |
| 240 |
<indexterm><primary>validation</primary> |
| 241 |
<secondary>SGML documents</secondary></indexterm> |
| 242 |
<indexterm><primary>DTDs</primary> |
| 243 |
<secondary>validating SGML documents against</secondary></indexterm> |
| 244 |
<indexterm><primary>instance (DocBook document)</primary></indexterm> |
| 245 |
|
| 246 |
Because an &SGML;/&XML; document has an associated &DTD; that |
| 247 |
describes the valid, logical structures of the document, you can test |
| 248 |
the logical structure of any particular document against the |
| 249 |
&DTD;. This process is performed by a <firstterm>parser</firstterm>. An |
| 250 |
&SGML; processor must begin by parsing the document and determining if |
| 251 |
it is valid, that is, if it conforms to the rules specified in the |
| 252 |
&DTD;. &XML; processors are not required to |
| 253 |
check for validity, but it's always a good idea to check for validity |
| 254 |
when authoring. Because you can test and validate the |
| 255 |
structure of an &SGML;/&XML; document with software, a DocBook |
| 256 |
document containing a first-level section followed immediately by a |
| 257 |
third-level section will be identified as invalid, meaning that it's |
| 258 |
not a valid <firstterm>instance</firstterm> or example of a document |
| 259 |
defined by the DocBook &DTD;. Presumably, a document with a logical |
| 260 |
structure won't normally jump from a first- to a third-level section, |
| 261 |
so the rule is a safeguard—but not a guarantee—of good |
| 262 |
writing, or at the very least, reasonable structure. A parser also |
| 263 |
verifies that the names of the tags are correct and that tags |
| 264 |
requiring an ending tag have them. This means that a valid document is |
| 265 |
also one that should format correctly, without runs of paragraphs |
| 266 |
incorrectly appearing in bold type or similar monstrosities that |
| 267 |
everyone has seen in print at one time or another. For more |
| 268 |
information about &SGML;/&XML; parsers, see <xref linkend="ch-parse"/>. |
| 269 |
</para> |
| 270 |
<para> |
| 271 |
In general, adherence to the explicit rules of structure and markup in |
| 272 |
a &DTD; is a useful and reassuring guarantee of consistency and |
| 273 |
reliability within documents, across document sets, and over |
| 274 |
time. This makes &SGML;/&XML; markup particularly desirable to |
| 275 |
corporations or governments that have large sets of documents to |
| 276 |
manage, but it is a boon to the individual writer as well. |
| 277 |
</para> |
| 278 |
<sect3> |
| 279 |
<title>How can this markup help you?</title> |
| 280 |
<para> |
| 281 |
<indexterm><primary>semantic markup</primary> |
| 282 |
<secondary>presentation media, different</secondary></indexterm> |
| 283 |
Semantic markup makes your documents more amenable to interpretation |
| 284 |
by software, especially publishing software. You can publish a white |
| 285 |
paper, authored as a DocBook <sgmltag>Article</sgmltag>, in the |
| 286 |
following formats: |
| 287 |
<indexterm><primary>articles</primary> |
| 288 |
<secondary>formats, listed</secondary></indexterm> |
| 289 |
<indexterm><primary>journal articles</primary></indexterm> |
| 290 |
|
| 291 |
</para> |
| 292 |
<itemizedlist> |
| 293 |
<listitem><para>On the Web in &HTML;</para> |
| 294 |
</listitem> |
| 295 |
<listitem><para>As a standalone document on 8½×11 paper</para> |
| 296 |
</listitem> |
| 297 |
<listitem><para>As part of a quarterly journal, in a 6×9 format |
| 298 |
</para> |
| 299 |
</listitem> |
| 300 |
<listitem><para>In Braille</para> |
| 301 |
</listitem> |
| 302 |
<listitem><para>In audio</para> |
| 303 |
</listitem> |
| 304 |
</itemizedlist> |
| 305 |
<para> |
| 306 |
You can produce each of these publications from exactly the same |
| 307 |
source document using the presentational techniques best suited to |
| 308 |
both the content of the document and the presentation medium. This |
| 309 |
versatility also frees the author to concentrate on the document |
| 310 |
content. For example, as we write this book, we don't know exactly how |
| 311 |
O'Reilly will choose to present chapter headings, bulleted lists, |
| 312 |
&SGML; terms, or any of the other semantic features. And we don't |
| 313 |
care. It's irrelevant; whatever presentation is chosen, the &SGML; |
| 314 |
sources will be transformed automatically into that style. |
| 315 |
</para> |
| 316 |
<para> |
| 317 |
Semantic markup can relieve the author of other, more significant |
| 318 |
burdens as well (after all, careful use of paragraph and character |
| 319 |
styles in a word processor document theoretically allows us to change |
| 320 |
the presentation independently from the document). Using semantic |
| 321 |
markup opens up your documents to a world of possibilities. Documents |
| 322 |
become, in a loose sense, databases of information. Programs can |
| 323 |
compile, retrieve, and otherwise manipulate the documents in |
| 324 |
predictable, useful ways. |
| 325 |
</para> |
| 326 |
<para> |
| 327 |
<indexterm><primary>links</primary> |
| 328 |
<secondary>SGML documents, maintaining</secondary></indexterm> |
| 329 |
<indexterm><primary>elements</primary> |
| 330 |
<secondary>linking to references</secondary></indexterm> |
| 331 |
|
| 332 |
Consider the online version of this book: almost every element name |
| 333 |
(<sgmltag>Article</sgmltag>, <sgmltag>Book</sgmltag>, and so on) is a |
| 334 |
hyperlink to the reference page that describes that |
| 335 |
element. Maintaining these links by hand would be tedious and might be |
| 336 |
unreliable, as well. Instead, every element name is marked as an |
| 337 |
element using <sgmltag>SGMLTag</sgmltag>: a <sgmltag>Book</sgmltag> is |
| 338 |
a <literal><sgmltag class="starttag">sgmltag</sgmltag>Book<sgmltag class="endtag">sgmltag</sgmltag></literal>. |
| 339 |
</para> |
| 340 |
<para> |
| 341 |
Because each element name in this book is tagged semantically, the |
| 342 |
program that produces the online version can determine which |
| 343 |
occurrences of the word “book” in the text are actually |
| 344 |
references to the <sgmltag>Book</sgmltag> element. The program can |
| 345 |
then automatically generate the appropriate hyperlink when it should. |
| 346 |
</para> |
| 347 |
<para> |
| 348 |
There's one last point to make about the versatility of &SGML; |
| 349 |
documents: how much you have depends on the &DTD;. If you take a good |
| 350 |
photo with a high resolution lens, you can print it and copy it and |
| 351 |
scan it and put it on the Web, and it will look good. If you start |
| 352 |
with a low-resolution picture it will not survive those |
| 353 |
transformations so well. DocBook &SGML;/&XML; has this advantage over, |
| 354 |
say, &HTML;: DocBook has specific and unambiguous semantic and |
| 355 |
structural markup, because you can convert its documents with ease |
| 356 |
into other presentational forms, and search them more precisely. If |
| 357 |
you start with &HTML;, whose markup is at a lower resolution than |
| 358 |
DocBook's, your versatility and searchability is substantially |
| 359 |
restricted and cannot be improved. |
| 360 |
</para> |
| 361 |
</sect3> |
| 362 |
<sect3> |
| 363 |
<title>What are the shortcomings to structural authoring?</title> |
| 364 |
<para> |
| 365 |
There are a few significant shortcomings to structured authoring: |
| 366 |
</para> |
| 367 |
<itemizedlist> |
| 368 |
<listitem><para>It requires a significant change in the authoring |
| 369 |
process. Writing structured documents is very different from writing |
| 370 |
with a typical word processor, and change is difficult. In particular, |
| 371 |
authors don't like giving up control over the appearance of their |
| 372 |
words especially now that they have acquired it with the advent of |
| 373 |
word processors. But many publishing companies need authors to |
| 374 |
relinquish that control, because book design and production remains |
| 375 |
their job, not their authors'.</para> |
| 376 |
</listitem> |
| 377 |
<listitem><para>Because semantics are separate from appearance, in |
| 378 |
order to publish an &SGML;/&XML; document, a stylesheet or other tool |
| 379 |
must create the presentational form from the structural form. Writing |
| 380 |
stylesheets is a skill in its own right, and though not every author |
| 381 |
among a group of authors has to learn how to write them, someone has |
| 382 |
to.</para> |
| 383 |
</listitem> |
| 384 |
<listitem><para>Authoring tools for &SGML; documents can generally be |
| 385 |
pretty expensive. While it's not entirely unreasonable to edit |
| 386 |
&SGML;/&XML; documents with a simple text editor, it's a bit tedious |
| 387 |
to do so. However, there are a few free tools that are |
| 388 |
&SGML;-aware. The widespread interest in &XML; may well produce new, |
| 389 |
clever, and less expensive &XML; editing tools.</para> |
| 390 |
</listitem> |
| 391 |
</itemizedlist> |
| 392 |
</sect3> |
| 393 |
</sect2> |
| 394 |
</sect1> |
| 395 |
<sect1 id="ch01-elemattr"> |
| 396 |
<title>Elements and Attributes</title> |
| 397 |
<para> |
| 398 |
<indexterm><primary>elements</primary> |
| 399 |
<secondary>attributes</secondary></indexterm> |
| 400 |
<indexterm><primary>attributes</primary> |
| 401 |
<secondary>elements and</secondary></indexterm> |
| 402 |
<indexterm><primary>elements</primary> |
| 403 |
<secondary>attributes</secondary><seealso>attributes</seealso></indexterm> |
| 404 |
<indexterm><primary>empty elements</primary></indexterm> |
| 405 |
<indexterm><primary>end tags</primary> |
| 406 |
<secondary>empty elements, not requiring</secondary></indexterm> |
| 407 |
<indexterm><primary>cross references</primary></indexterm> |
| 408 |
<indexterm><primary>entities</primary> |
| 409 |
<secondary>SGML/XML markup</secondary></indexterm> |
| 410 |
|
| 411 |
&SGML;/&XML; markup consists primarily of |
| 412 |
<firstterm>elements</firstterm>, <firstterm>attributes</firstterm>, |
| 413 |
and <firstterm>entities</firstterm>. Elements are the terms we have |
| 414 |
been speaking about most, like <sgmltag>sect1</sgmltag>, that describe |
| 415 |
a document's content and structure. Most elements are represented by pairs |
| 416 |
of tags and |
| 417 |
mark the start and end of the construct they surround—for |
| 418 |
example, the &SGML; source for this particular paragraph begins with a |
| 419 |
<sgmltag class="starttag">para</sgmltag> tag and ends with a <sgmltag class="endtag">para</sgmltag> tag. Some elements are |
| 420 |
“empty” (such as DocBook's cross-reference element, |
| 421 |
<sgmltag class="starttag">xref</sgmltag>) and require no end |
| 422 |
tag.<footnote><para>In &XML;, this is written as |
| 423 |
<literal><xref/></literal>, as we'll see in the section <xref linkend="ch02-typexml"/>.</para></footnote> |
| 424 |
</para> |
| 425 |
<para> |
| 426 |
<indexterm><primary>ID attribute</primary> |
| 427 |
<secondary>SGML start tags</secondary></indexterm> |
| 428 |
<indexterm><primary>tags</primary> |
| 429 |
<secondary>identifiers (SGML)</secondary></indexterm> |
| 430 |
<indexterm><primary>end tags</primary> |
| 431 |
<secondary>attributes and</secondary></indexterm> |
| 432 |
<indexterm><primary>start tags</primary> |
| 433 |
<secondary>attribute ID, containing</secondary></indexterm> |
| 434 |
|
| 435 |
Elements can, but don't necessarily, include one or more attributes, |
| 436 |
which are additional terms that extend the function or refine the |
| 437 |
content of a given element. For instance, in DocBook a <sgmltag class="starttag">sect1</sgmltag> start tag can contain an |
| 438 |
identifier—an <sgmltag class="attribute">id</sgmltag> |
| 439 |
attribute—that will ultimately allow the writer to |
| 440 |
cross-reference it or enable a reader to retrieve it. End tags cannot |
| 441 |
contain attributes. A <sgmltag class="starttag">sect1</sgmltag> |
| 442 |
element with an <sgmltag class="attribute">id</sgmltag> attribute |
| 443 |
looks like this: |
| 444 |
</para> |
| 445 |
|
| 446 |
<screen><sect1 id="<replaceable>idvalue</replaceable>"></screen> |
| 447 |
|
| 448 |
<para> |
| 449 |
<indexterm><primary>namespaces</primary> |
| 450 |
<secondary>XML tags</secondary></indexterm> |
| 451 |
<indexterm><primary>tags</primary> |
| 452 |
<secondary>namespaces (XML)</secondary></indexterm> |
| 453 |
<indexterm><primary>validation</primary> |
| 454 |
<secondary>namespace tags (XML), problems</secondary></indexterm> |
| 455 |
<indexterm><primary>XML</primary> |
| 456 |
<secondary>namespaces, using</secondary></indexterm> |
| 457 |
|
| 458 |
In &SGML;, the catalog of attributes that can occur on an element is |
| 459 |
predefined. You cannot add arbitrary attribute names to an |
| 460 |
element. Similarly, the values allowed for each attribute are |
| 461 |
predefined. In &XML;, the use of <ulink url="http://www.w3.org/TR/REC-xml-names/">namespaces</ulink> may allow you |
| 462 |
to add additional attributes to an element, but as of this writing, |
| 463 |
there's no way to perform validation on those attributes. |
| 464 |
</para> |
| 465 |
<para> |
| 466 |
<indexterm><primary>SystemItem element</primary> |
| 467 |
<secondary>subdividing into URL and email addresses</secondary></indexterm> |
| 468 |
<indexterm><primary>Role attribute</primary> |
| 469 |
<secondary>systemitem tags, subdividing</secondary></indexterm> |
| 470 |
|
| 471 |
The <sgmltag class="attribute">id</sgmltag> attribute is one half of a |
| 472 |
cross reference. An <sgmltag class="attribute">idref</sgmltag> |
| 473 |
attribute on another element, for example <sgmltag class="starttag">xref linkend=”idvalue” |
| 474 |
</sgmltag>, provides the other half. These attributes provide whatever |
| 475 |
application might process the &SGML; source with the data needed |
| 476 |
either to make a hypertext link or to substitute a named and/or numbered cross |
| 477 |
reference in place of the <sgmltag class="starttag"> |
| 478 |
xref</sgmltag>. Another use for attributes is to specify subclasses of |
| 479 |
certain elements. For instance, you can subdivide DocBook's <sgmltag class="starttag">systemitem</sgmltag> into <acronym>URL</acronym>s and |
| 480 |
email addresses by making the content of the <sgmltag class="attribute">role</sgmltag> attribute the distinction between |
| 481 |
them, as in <sgmltag class="starttag">systemitem role="URL"</sgmltag> |
| 482 |
versus <sgmltag class="starttag">systemitem |
| 483 |
role="emailaddr"</sgmltag>. |
| 484 |
</para> |
| 485 |
</sect1> |
| 486 |
<sect1 id="s-entities"><title>Entities</title> |
| 487 |
<para> |
| 488 |
<indexterm><primary>entities</primary> |
| 489 |
<secondary>functions</secondary></indexterm> |
| 490 |
<indexterm><primary>parsed entities</primary></indexterm> |
| 491 |
<indexterm><primary>unparsed entities</primary></indexterm> |
| 492 |
<indexterm><primary>names</primary> |
| 493 |
<secondary>assigning to data (entities)</secondary></indexterm> |
| 494 |
|
| 495 |
Entities are a fundamental concept in &SGML; and &XML;, and can be |
| 496 |
somewhat daunting at first. They serve a number of related, but |
| 497 |
slightly different functions, and this makes them a little bit |
| 498 |
complicated. |
| 499 |
</para> |
| 500 |
<para> |
| 501 |
In the most general terms, entities allow you to assign a name to some |
| 502 |
chunk of data, and use that name to refer to that data. The complexity |
| 503 |
arises because there are two different contexts in which you can use |
| 504 |
entities (in the &DTD; and in your documents), two types of entities |
| 505 |
(parsed and unparsed), and two or three different ways in which the |
| 506 |
entities can point to the chunk of data that they name. |
| 507 |
</para> |
| 508 |
<para> |
| 509 |
In the rest of this section, we'll describe each of the commonly |
| 510 |
encountered entity types. If you find the material in this section |
| 511 |
confusing, feel free to skip over it now and come back to it later. |
| 512 |
We'll refer to the different types of entities as the need arises in |
| 513 |
our discussion of DocBook. Come back to this section when you're |
| 514 |
looking for more detail. |
| 515 |
</para> |
| 516 |
<para> |
| 517 |
Entities can be divided into two broad categories, <firstterm>general |
| 518 |
entities</firstterm> and <firstterm>parameter entities</firstterm>. |
| 519 |
Parameter entities are most often used in the &DTD;, not in documents, |
| 520 |
so we'll describe them last. Before you can use any type of entity, it |
| 521 |
must be formally declared. This is typically done in the document |
| 522 |
prologue, as we'll explain in <xref linkend="ch-create"/>, but we will |
| 523 |
show you how to declare each of the entities discussed here. |
| 524 |
</para> |
| 525 |
<sect2><title>General Entities</title> |
| 526 |
<para> |
| 527 |
<indexterm><primary>general entities</primary> |
| 528 |
<secondary>external and internal</secondary></indexterm> |
| 529 |
<indexterm><primary>entities</primary> |
| 530 |
<secondary>general</secondary></indexterm> |
| 531 |
In use, general entities are introduced with an ampersand (&) and end with |
| 532 |
a semicolon (;). Within the category of general entities, there are |
| 533 |
two types: <firstterm>internal general entities</firstterm> and |
| 534 |
<firstterm>external general entities</firstterm>. |
| 535 |
</para> |
| 536 |
<sect3><title>Internal general entities</title> |
| 537 |
<para> |
| 538 |
<indexterm><primary>internal general entities</primary></indexterm> |
| 539 |
<indexterm><primary>names</primary> |
| 540 |
<secondary>text, associating with (internal general entities)</secondary></indexterm> |
| 541 |
<indexterm><primary>text</primary> |
| 542 |
<secondary>entity, declaring as</secondary></indexterm> |
| 543 |
|
| 544 |
With internal entities, you can associate an essentially arbitrary |
| 545 |
piece of text (which may have other markup, including references to |
| 546 |
other entities) with a name. You can then include that text by |
| 547 |
referring to its name. For example, if your document frequently refers |
| 548 |
to, say, “O'Reilly & Associates,” you might declare it |
| 549 |
as an entity: |
| 550 |
</para> |
| 551 |
|
| 552 |
<screen><![CDATA[<!ENTITY ora "O'Reilly & Associates">]]></screen> |
| 553 |
|
| 554 |
<para> |
| 555 |
Then, instead of typing it out each time, you can insert it as needed |
| 556 |
in your document with the entity reference <sgmltag class="genentity">ora</sgmltag>, simply to save time. Note that this |
| 557 |
entity declaration includes another entity reference within it. |
| 558 |
That's perfectly valid as long as the reference isn't directly or |
| 559 |
indirectly recursive. |
| 560 |
</para> |
| 561 |
<para> |
| 562 |
<indexterm><primary>entities</primary> |
| 563 |
<secondary>adding directly to DTD</secondary></indexterm> |
| 564 |
|
| 565 |
If you find that you use a number of entities across many documents, |
| 566 |
you can add them directly to the &DTD; and avoid having to include the |
| 567 |
declarations in each document. See the discussion of |
| 568 |
<filename>dbgenent.mod</filename> in <xref linkend="app-customizing"/>. |
| 569 |
</para> |
| 570 |
</sect3> |
| 571 |
<sect3 id="s-egenent"><title>External general entities</title> |
| 572 |
<para> |
| 573 |
<indexterm><primary>external general entities</primary></indexterm> |
| 574 |
<indexterm><primary>SGML</primary> |
| 575 |
<secondary>external documents, referencing (external general entities)</secondary></indexterm> |
| 576 |
<indexterm><primary>parsers</primary> |
| 577 |
<secondary>external file text, inserting</secondary></indexterm> |
| 578 |
<indexterm><primary>files</primary> |
| 579 |
<secondary>external, referencing</secondary></indexterm> |
| 580 |
|
| 581 |
With external entities, you can reference other documents from within |
| 582 |
your document. If these entities contain document text (&SGML; or |
| 583 |
&XML;), then references to them cause the parser to insert the text of |
| 584 |
the external file directly into your document (these are called parsed |
| 585 |
entities). In this way, you can use entities to divide your single, |
| 586 |
logical document into physically distinct chunks. For example, you |
| 587 |
might break your document into four chapters and store them in |
| 588 |
separate files. At the top of your document, you would include entity |
| 589 |
declarations to reference the four files: |
| 590 |
</para> |
| 591 |
|
| 592 |
<screen><![CDATA[<!ENTITY ch01 SYSTEM "ch01.sgm"> |
| 593 |
<!ENTITY ch02 SYSTEM "ch02.sgm"> |
| 594 |
<!ENTITY ch03 SYSTEM "ch03.sgm"> |
| 595 |
<!ENTITY ch04 SYSTEM "ch04.sgm">]]></screen> |
| 596 |
|
| 597 |
<para> |
| 598 |
Your <sgmltag>Book</sgmltag> now consists simply of references to the |
| 599 |
entities: |
| 600 |
</para> |
| 601 |
|
| 602 |
<screen><book> |
| 603 |
&ch01; |
| 604 |
&ch02; |
| 605 |
&ch03; |
| 606 |
&ch04; |
| 607 |
</book></screen> |
| 608 |
|
| 609 |
<para> |
| 610 |
<indexterm><primary>unparsed entities</primary></indexterm> |
| 611 |
<indexterm><primary>notations (unparsed entities)</primary></indexterm> |
| 612 |
|
| 613 |
Sometimes it's useful to reference external files that don't contain |
| 614 |
document text. For example, you might want to reference an external |
| 615 |
graphic. You can do this with entities by declaring the type of data |
| 616 |
that's in the entity using a notation (these are called unparsed |
| 617 |
entities). For example, the following declaration declares the entity |
| 618 |
<literal>tree</literal> as an encapsulated PostScript image: |
| 619 |
</para> |
| 620 |
|
| 621 |
<screen><![CDATA[<!ENTITY tree SYSTEM "tree.eps" NDATA EPS>]]></screen> |
| 622 |
|
| 623 |
<para> |
| 624 |
<indexterm><primary>elements</primary> |
| 625 |
<secondary>entity attributes</secondary></indexterm> |
| 626 |
|
| 627 |
Entities declared this way cannot be inserted directly into your |
| 628 |
document. Instead, they must be used as entity attributes to elements: |
| 629 |
</para> |
| 630 |
|
| 631 |
<screen><![CDATA[<graphic entityref="tree"></graphic>]]></screen> |
| 632 |
|
| 633 |
<para> |
| 634 |
Conversely, you cannot use entities declared without a notation as the |
| 635 |
value of an entity attribute. |
| 636 |
</para> |
| 637 |
</sect3> |
| 638 |
<sect3 id="s-specchar"><title>Special characters</title> |
| 639 |
<para> |
| 640 |
<indexterm><primary>markup</primary> |
| 641 |
<secondary>distinguishing from content</secondary></indexterm> |
| 642 |
<indexterm><primary>start tags</primary> |
| 643 |
<secondary>beginning</secondary></indexterm> |
| 644 |
<indexterm><primary>end tags</primary> |
| 645 |
<secondary>beginning</secondary></indexterm> |
| 646 |
In order for the parser to recognize markup in your document, it must |
| 647 |
be able to distinguish markup from content. It does this with two |
| 648 |
special characters: “<,” which identifies the beginning |
| 649 |
of a start or end tag, and “&,” which identifies the |
| 650 |
beginning of an entity reference.<footnote> |
| 651 |
<para> |
| 652 |
<indexterm><primary>start characters, changing</primary></indexterm> |
| 653 |
In &XML;, these characters are fixed. In &SGML;, it is possible to |
| 654 |
change the markup start characters, but we won't consider that case |
| 655 |
here. If you change the markup start characters, you know what you're |
| 656 |
doing. While we're on the subject, in &SGML;, these characters only |
| 657 |
have their special meaning if they are followed by a name character. |
| 658 |
It is, in fact, valid in an <emphasis>&SGML;</emphasis> (but not an &XML;) |
| 659 |
document to write “O'Reilly & Associates” because the |
| 660 |
ampersand is not followed by a name character. Don't do this, however. |
| 661 |
<indexterm><primary>characters</primary> |
| 662 |
<secondary>entities</secondary> |
| 663 |
<tertiary>encoding as</tertiary></indexterm> |
| 664 |
<indexterm><primary>entities</primary> |
| 665 |
<secondary>characters</secondary></indexterm> |
| 666 |
<indexterm><primary>angle brackets</primary> |
| 667 |
<secondary>coding as entities</secondary></indexterm> |
| 668 |
</para> |
| 669 |
</footnote> |
| 670 |
If you want these characters to have their literal value, they must be |
| 671 |
encoded as entity references in your document. The entity reference |
| 672 |
<sgmltag class="genentity">lt</sgmltag> produces a left angle bracket; |
| 673 |
<sgmltag class="genentity">amp</sgmltag> produces the |
| 674 |
ampersand.<footnote> |
| 675 |
<para> |
| 676 |
<indexterm><primary>marked sections</primary> |
| 677 |
<secondary>character sequence, ending</secondary></indexterm> |
| 678 |
|
| 679 |
The sequence of characters that end a marked section (see <xref linkend="s-ms"/>), such as ]]> must also be encoded with at least |
| 680 |
one entity reference if it is not being used to end a marked section. |
| 681 |
For this purpose, you can use the entity reference <sgmltag class="genentity">gt</sgmltag> for the final right angle bracket. |
| 682 |
</para> |
| 683 |
</footnote> |
| 684 |
</para> |
| 685 |
<para> |
| 686 |
<indexterm><primary>parsers</primary> |
| 687 |
<secondary>entity references, interpreting</secondary></indexterm> |
| 688 |
|
| 689 |
If you do not encode each of these as their respective entity |
| 690 |
references, then an &SGML; parser or application is likely to |
| 691 |
interpret them as characters introducing elements or entities (an |
| 692 |
&XML; parser will always interpret them this way); consequently, they |
| 693 |
won't appear as you intended. If you wish to cite text that contains |
| 694 |
literal ampersands and less-than signs, you need to transform these |
| 695 |
two characters into entity references before they are included in a |
| 696 |
DocBook document. The only other alternative is to incorporate text |
| 697 |
that includes them in your document through some process that avoids |
| 698 |
the parser. |
| 699 |
</para> |
| 700 |
<para> |
| 701 |
<indexterm><primary>data entities</primary></indexterm> |
| 702 |
<indexterm><primary>numeric character references</primary></indexterm> |
| 703 |
|
| 704 |
In &SGML;, character entities are frequently declared using a third |
| 705 |
entity category (one that we deliberately chose to overlook), called |
| 706 |
<firstterm>data entities</firstterm>. In &XML;, these are declared using |
| 707 |
numeric character references. Numeric character references resemble |
| 708 |
entity references, but technically aren't the same. They have the form |
| 709 |
<literal>&#<replaceable>999</replaceable>;</literal>, in which |
| 710 |
“999” is the numeric character number. |
| 711 |
</para> |
| 712 |
<para> |
| 713 |
<indexterm><primary>Unicode character set</primary> |
| 714 |
<secondary>character numbers (XML)</secondary></indexterm> |
| 715 |
<indexterm><primary>hexadecimal numeric character references (XML)</primary></indexterm> |
| 716 |
|
| 717 |
In &XML;, the numeric character number is always the Unicode character |
| 718 |
number. In addition, &XML; allows hexadecimal numeric character |
| 719 |
references of the form |
| 720 |
<literal>&#x<replaceable>hhhh</replaceable>;</literal>. In &SGML;, the |
| 721 |
numeric character number is a number from the document character set |
| 722 |
that's declared in the &SGML; declaration. |
| 723 |
</para> |
| 724 |
<para> |
| 725 |
<indexterm><primary>special characters, encoding as entities</primary></indexterm> |
| 726 |
|
| 727 |
Character entities are also used to give a name to special characters |
| 728 |
that can't otherwise be typed or are not portable across applications |
| 729 |
and operating systems. You can then include these characters in your |
| 730 |
document by refering to their entity name. Instead of using the often |
| 731 |
obscure and inconsistent key combinations of your particular word |
| 732 |
processor to type, say, an uppercase letter U with an umlaut (Ü), |
| 733 |
you type in an entity for it instead. For instance, the entity for an |
| 734 |
uppercase letter U with an umlaut has been defined as the entity |
| 735 |
<literal>Uuml</literal>, so you would type in <sgmltag class="genentity">Uuml</sgmltag> to reference it instead of the actual |
| 736 |
character. The &SGML; application that eventually processes your |
| 737 |
document for presentation will match the entity to your platform's |
| 738 |
handling of special characters in order to render it |
| 739 |
appropriately. |
| 740 |
</para> |
| 741 |
</sect3> |
| 742 |
</sect2> |
| 743 |
<sect2><title>Parameter Entities</title> |
| 744 |
<para> |
| 745 |
<indexterm><primary>entities</primary> |
| 746 |
<secondary>parameter entities</secondary><see>parameter entities</see></indexterm> |
| 747 |
<indexterm><primary>parameter entities</primary></indexterm> |
| 748 |
|
| 749 |
Parameter entities are only recognized in markup declarations (in the |
| 750 |
&DTD;, for example). Instead of beginning with an ampersand, they |
| 751 |
begin with a percent sign. Parameter entities are most frequently |
| 752 |
used to customize the &DTD;. For a detailed discussion of this topic, |
| 753 |
see <xref linkend="app-customizing"/>. Following are some other uses for |
| 754 |
them. |
| 755 |
</para> |
| 756 |
<sect3 id="s-ms"><title>Marked sections</title> |
| 757 |
<para> |
| 758 |
<indexterm><primary>marked sections</primary></indexterm> |
| 759 |
<indexterm><primary>SGML</primary> |
| 760 |
<secondary>marked sections</secondary></indexterm> |
| 761 |
<indexterm><primary>XML</primary> |
| 762 |
<secondary>marked sections</secondary></indexterm> |
| 763 |
|
| 764 |
You might use a parameter entity reference in an &SGML; document in a |
| 765 |
marked section. Marking sections is a mechanism for indicating that |
| 766 |
special processing should apply to a particular block of text. Marked |
| 767 |
sections are introduced by the special sequence |
| 768 |
<literal><![<replaceable>keyword</replaceable>[</literal> and end |
| 769 |
with <literal>]]></literal>. In &SGML;, marked sections can appear |
| 770 |
in both &DTD;s and document instances. In &XML;, they're only allowed |
| 771 |
in the &DTD;.<footnote> |
| 772 |
<para> |
| 773 |
<indexterm><primary>CDATA</primary> |
| 774 |
<secondary>marked sections</secondary></indexterm> |
| 775 |
Actually, CDATA marked sections are allowed in an &XML; document, but |
| 776 |
the keyword cannot be a parameter entity, and it must be typed |
| 777 |
literally. See the examples on this page. |
| 778 |
</para> |
| 779 |
</footnote> |
| 780 |
</para> |
| 781 |
<para> |
| 782 |
<indexterm><primary>keywords</primary> |
| 783 |
<secondary>marked sections</secondary></indexterm> |
| 784 |
<indexterm><primary>INCLUDE keyword (marked section)</primary></indexterm> |
| 785 |
<indexterm><primary>IGNORE keyword (marked section)</primary></indexterm> |
| 786 |
|
| 787 |
The most common keywords are <literal>INCLUDE</literal>, which |
| 788 |
indicates that the text in the marked section should be included in |
| 789 |
the document; <literal>IGNORE</literal>, which indicates that the text |
| 790 |
in the marked section should be ignored (it completely disappears from |
| 791 |
the parsed document); and <literal>CDATA</literal>, which indicates |
| 792 |
that all markup characters within that section should be ignored |
| 793 |
except for the closing characters <literal>]]></literal>. |
| 794 |
</para> |
| 795 |
<para> |
| 796 |
<indexterm><primary>SGML</primary> |
| 797 |
<secondary>keywords as parameter entities</secondary></indexterm> |
| 798 |
In &SGML;, these keywords can be parameter entities. For example, you |
| 799 |
might declare the following parameter entity in your document: |
| 800 |
</para> |
| 801 |
|
| 802 |
<screen><![CDATA[<!ENTITY % draft "INCLUDE">]]></screen> |
| 803 |
|
| 804 |
<para> |
| 805 |
Then you could put the sections of the document that are only applicable |
| 806 |
in a draft within marked sections: |
| 807 |
</para> |
| 808 |
|
| 809 |
<screen><![%draft;[ |
| 810 |
<para> |
| 811 |
This paragraph only appears in the draft version. |
| 812 |
</para> |
| 813 |
]]></screen> |
| 814 |
|
| 815 |
<para> |
| 816 |
When you're ready to print the final version, simply change the |
| 817 |
<literal>draft</literal> parameter entity declaration: |
| 818 |
</para> |
| 819 |
|
| 820 |
<screen><![CDATA[<!ENTITY % draft "IGNORE">]]></screen> |
| 821 |
|
| 822 |
<para> |
| 823 |
and publish the document. None of the draft sections will appear. |
| 824 |
<indexterm startref="SGMLbasicconceptch01" class="endofrange"/> |
| 825 |
<indexterm startref="XMLbasicconceptch01" class="endofrange"/> |
| 826 |
</para> |
| 827 |
</sect3> |
| 828 |
</sect2> |
| 829 |
</sect1> |
| 830 |
<sect1 id="ch01-wheredocbook"><title>How Does DocBook Fit In?</title> |
| 831 |
<para> |
| 832 |
<indexterm><primary>DocBook DTD</primary> |
| 833 |
<secondary>history and overview</secondary></indexterm> |
| 834 |
|
| 835 |
DocBook is a very popular set of tags for describing books, articles, |
| 836 |
and other prose documents, particularly technical |
| 837 |
documentation. DocBook is defined using the native &DTD; syntax of |
| 838 |
&SGML; and &XML;. Like &HTML;, DocBook is an example of a markup |
| 839 |
language defined in &SGML;/&XML;. |
| 840 |
</para> |
| 841 |
<sect2><title>A Short DocBook History</title> |
| 842 |
<para> |
| 843 |
DocBook is almost 10 years old. It began in 1991 as a joint project of |
| 844 |
HaL Computer Systems and O'Reilly. Its popularity grew, and eventually |
| 845 |
it spawned its own maintenance organization, the Davenport Group. In |
| 846 |
mid-1998, it became a Technical Committee (<acronym>TC</acronym>) of |
| 847 |
the Organization for the Advancement of Structured Information |
| 848 |
Standards (<acronym>OASIS</acronym>). |
| 849 |
</para> |
| 850 |
<sect3><title>The HaL and O'Reilly era</title> |
| 851 |
<para> |
| 852 |
<indexterm><primary>Open Software Foundation</primary></indexterm> |
| 853 |
<indexterm><primary>troff markup (UNIX documentation)</primary></indexterm> |
| 854 |
<indexterm><primary>UNIX</primary> |
| 855 |
<secondary>DocBook DTD, development</secondary></indexterm> |
| 856 |
|
| 857 |
The DocBook &DTD; was originally designed and implemented by HaL |
| 858 |
Computer Systems and O'Reilly & Associates around 1991. It was |
| 859 |
developed primarily to facilitate the exchange of &UNIX; documentation |
| 860 |
originally marked up in <command>troff</command>. Its design appears |
| 861 |
to have been based partly on input from &SGML; interchange projects |
| 862 |
conducted by the Unix International and Open Software Foundation |
| 863 |
consortia. |
| 864 |
</para> |
| 865 |
<para> |
| 866 |
<indexterm><primary>Davenport Group (DocBook maintenance)</primary></indexterm> |
| 867 |
When DocBook <acronym>V1.1</acronym> was published, discussion about |
| 868 |
its revision and maintenance began in earnest in the Davenport Group, |
| 869 |
a forum created by O'Reilly for computer documentation |
| 870 |
producers. Version 1.2 was influenced strongly by |
| 871 |
Novell and Digital. |
| 872 |
</para> |
| 873 |
<para> |
| 874 |
In 1994, the Davenport Group became an officially chartered entity |
| 875 |
responsible for DocBook's maintenance. DocBook |
| 876 |
<acronym>V1.2.2</acronym> was published simultaneously. The founding |
| 877 |
sponsors of this incarnation of Davenport include the following |
| 878 |
people: |
| 879 |
<itemizedlist spacing="compact"> |
| 880 |
<listitem><para>Jon Bosak, Novell</para></listitem> |
| 881 |
<listitem><para>Dale Dougherty, O'Reilly & Associates</para></listitem> |
| 882 |
<listitem><para>Ralph Ferris, Fujitsu <acronym>OSSI</acronym></para></listitem> |
| 883 |
<listitem><para>Dave Hollander, Hewlett-Packard</para></listitem> |
| 884 |
<listitem><para>Eve Maler, Digital Equipment Corporation</para></listitem> |
| 885 |
<listitem><para>Murray Maloney, <acronym>SCO</acronym></para></listitem> |
| 886 |
<listitem><para>Conleth O'Connell, HaL Computer Systems</para></listitem> |
| 887 |
<listitem><para>Nancy Paisner, Hitachi Computer Products</para></listitem> |
| 888 |
<listitem><para>Mike Rogers, SunSoft</para></listitem> |
| 889 |
<listitem><para>Jean Tappan, Unisys</para></listitem> |
| 890 |
</itemizedlist> |
| 891 |
</para> |
| 892 |
</sect3> |
| 893 |
<sect3><title>The Davenport era</title> |
| 894 |
<para> |
| 895 |
Under the auspices of the Davenport Group, the DocBook &DTD; began to |
| 896 |
widen its scope. It was now being used by a much wider audience, and |
| 897 |
for new purposes, such as direct authoring with &SGML;-aware tools, |
| 898 |
and publishing directly to paper. As the largest users of DocBook, |
| 899 |
Novell and Sun had a heavy influence on its design. |
| 900 |
</para> |
| 901 |
<para> |
| 902 |
<indexterm><primary>DocBook DTD</primary> |
| 903 |
<secondary>releases, rules for new versions</secondary></indexterm> |
| 904 |
|
| 905 |
In order to help users manage change, the new Davenport charter established |
| 906 |
the following rules for DocBook releases: |
| 907 |
<itemizedlist> |
| 908 |
<listitem><para>Minor versions (<quote>point releases</quote> such as |
| 909 |
<acronym>V2.2</acronym>) could add to the markup model, but could not |
| 910 |
change it in a backward-incompatible way. For example, a new kind of |
| 911 |
list element could be added, but it would not be acceptable for the |
| 912 |
existing itemized-list model to start requiring two list items inside |
| 913 |
it instead of only one. Thus, any document conforming to version |
| 914 |
<replaceable>n</replaceable>.0 would also conform to |
| 915 |
<replaceable>n</replaceable>.<replaceable>m</replaceable>.</para> |
| 916 |
</listitem> |
| 917 |
<listitem><para>Major versions (such as <acronym>V3.0</acronym>) could |
| 918 |
both add to the markup model and make backward-incompatible |
| 919 |
changes. However, the changes would have to be announced in the last |
| 920 |
major release.</para> |
| 921 |
</listitem> |
| 922 |
<listitem><para>Major-version introductions must be separated by at |
| 923 |
least a year.</para> |
| 924 |
</listitem> |
| 925 |
</itemizedlist> |
| 926 |
</para> |
| 927 |
<para> |
| 928 |
<indexterm><primary>DocBook DTD</primary> |
| 929 |
<secondary>XML</secondary> |
| 930 |
<tertiary>XML-compliant version</tertiary></indexterm> |
| 931 |
<indexterm><primary>XML</primary> |
| 932 |
<secondary>DocBook version compliant with</secondary></indexterm> |
| 933 |
|
| 934 |
<acronym>V3.0</acronym> was released in January 1997. After that time, |
| 935 |
although DocBook's audience continued to grow, many of the Davenport |
| 936 |
Group stalwarts became involved in the &XML; effort, and development |
| 937 |
slowed dramatically. The idea of creating an official &XML;-compliant |
| 938 |
version of DocBook was discussed, but not implemented. (For more |
| 939 |
detailed information about DocBook <acronym>V3.0</acronym> and plans |
| 940 |
for subsequent versions, see <xref linkend="app-versions"/>.) |
| 941 |
</para> |
| 942 |
<para> |
| 943 |
<indexterm><primary>OASIS</primary> |
| 944 |
<secondary>DocBook Technical Committee</secondary></indexterm> |
| 945 |
|
| 946 |
The sponsors wanted to close out Davenport in an orderly way to ensure |
| 947 |
that DocBook users would be supported. It was suggested that |
| 948 |
<acronym>OASIS</acronym> become DocBook's new home. An |
| 949 |
<acronym>OASIS</acronym> DocBook Technical Committee was formed in |
| 950 |
July, 1998, with Eduardo Gutentag of Sun Microsystems as chair. |
| 951 |
</para> |
| 952 |
</sect3> |
| 953 |
<sect3> |
| 954 |
<title>The <acronym>OASIS</acronym> era</title> |
| 955 |
<para> |
| 956 |
The <ulink url="http://www.oasis-open.org/docbook/">DocBook Technical |
| 957 |
Commitee</ulink> is continuing the work started by the |
| 958 |
Davenport Group. The transition from Davenport to |
| 959 |
<acronym>OASIS</acronym> has been very smooth, in part because the |
| 960 |
core design team consists of essentially the same individuals (we all |
| 961 |
just changed hats). |
| 962 |
</para> |
| 963 |
<para> |
| 964 |
DocBook <acronym>V3.1</acronym>, published in February 1999, was the |
| 965 |
first <acronym>OASIS</acronym> release. It integrated a number of |
| 966 |
changes that had been <quote>in the wings</quote> for some time. |
| 967 |
</para> |
| 968 |
|
| 969 |
<para>In February of 2001, OASIS made DocBook SGML V4.1 and DocBook XML V4.1.2 |
| 970 |
<ulink url="http://lists.oasis-open.org/archives/members/200102/msg00000.html">official |
| 971 |
OASIS Specifications</ulink>. |
| 972 |
</para> |
| 973 |
|
| 974 |
<para><ulink url="http://www.oasis-open.org/docbook/specs/cs-docbook-docbook-4.2.html">Version 4.2</ulink> of the DocBook &DTD;, for both &SGML; and &XML;, was |
| 975 |
released in July 2002.</para> |
| 976 |
|
| 977 |
<para> |
| 978 |
The committee continues new DocBook development to ensure |
| 979 |
that the &DTD; continues to meet the needs of its users. Forthcoming |
| 980 |
and experimental work includes: |
| 981 |
</para> |
| 982 |
|
| 983 |
<itemizedlist> |
| 984 |
<listitem><para>A V5.0 DTD projected for release no earlier than the end of |
| 985 |
2002. |
| 986 |
</para></listitem> |
| 987 |
<listitem><para>Experimental |
| 988 |
<ulink url="http://www.oasis-open.org/committees/relax-ng/">RELAX NG</ulink> schemas |
| 989 |
<ulink url="http://www.oasis-open.org/docbook/relaxng">available</ulink>.</para></listitem> |
| 990 |
<listitem><para>Experimental |
| 991 |
<ulink url="http://www.w3.org/XML/Schema">W3C XML Schema</ulink> versions |
| 992 |
<ulink url="http://www.oasis-open.org/docbook/xmlschema/">available</ulink>.</para></listitem> |
| 993 |
<listitem><para>Experimental |
| 994 |
<ulink url="http://www.xml.gr.jp/relax/">RELAX</ulink> schemas |
| 995 |
<ulink url="http://www.oasis-open.org/docbook/relax/">available</ulink>.</para></listitem> |
| 996 |
<listitem><para>Experimental |
| 997 |
<ulink url="http://www.thaiopensource.com/trex/">TREX</ulink> schemas |
| 998 |
<ulink url="http://www.oasis-open.org/docbook/trex/">available</ulink>.</para></listitem> |
| 999 |
</itemizedlist> |
| 1000 |
|
| 1001 |
<indexterm startref="XMLgetstart" class="endofrange"/> |
| 1002 |
<indexterm startref="getstartSGML" class="endofrange"/> |
| 1003 |
|
| 1004 |
</sect3> |
| 1005 |
</sect2> |
| 1006 |
</sect1> |
| 1007 |
</chapter> |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|