<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sect1 PUBLIC "//OASIS//DTD DocBook XML V4.2//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<sect1>
  <title>テキスト処理について<!-- The World of Text Processing --></title>
  <para>私は ``テキストプロセッシング(処理)'' という言葉を ``ワードプロセッシング''とは区別し、Unix の最初の本から学んだのと同じ意味で使っています。
  それはこの本の私が最初に Troff と(WYSIWYG に相対する)テキスト処理の背後にある哲学を発見した場所にありました。
    <!-- I use the words ``Text Processing'' to differentiate from ``Word
    Processing'' as I learned them from my first book in UNIX.  It
    was in this book where I first discovered Troff and the
    philosophy behind Text Processing (vs. WYSIWYG). -->
  </para>
  <para>テキスト処理は文書を要素に分けます:
    <!-- Text processing separates the elements of a document: -->
    <itemizedlist>
      <listitem>
	<para> 内容<!-- Content --></para>
      </listitem>
      <listitem>
	<para>構造<!-- Structure --></para>
      </listitem>
      <listitem>
	<para>スタイル<!-- Style --></para>
      </listitem>
    </itemizedlist>
  </para>
  <para>基本となる哲学は、筆者はスタイルよりもむしろ内容と構造に集中するべきであるということです。構造は大抵筆者の用途に合うように
  あらかじめ定義されている(または DocBook のように標準化されている)ので、結局一番関心を抱くべき内容にきっちりと集中することになります。
    <!-- The basic philosophy is that authors should concentrate on
    content and structure rather than on style. Since structure is
    usually predefined (or standardized like Docbook) to meet the
    purpose of the author, the author ends up concentrating strictly
    on the content, which should be his primary interest. -->
  </para>
  <para>テキスト処理においては筆者はテキストエディタのような単純なツールか、LyX や Emacs のような特別な構造化テキストエディタを
  使うことができます。いずれにせよ、それらの情報は常にコンピュータでもっとも自然なファイル形式 - <emphasis>テキストファイル</emphasis> -
  として保存されます。これは多くの問題点(その大部分については <xref linkend="wpf" />で述べました)について
  非常に理にかなった解決策を示しています。
    <!-- In text processing, authors can use the simplest of tools like a
    text editor, or they can use specialized structured text editors
    like LyX or Emacs. In any case, their information is always
    stored in the most natural of computer formats: <emphasis>plain
    text</emphasis>. This makes a lot of sense for a number of
    reasons, many of which where listed in <xref linkend="wpf" />. -->
  </para>
  <sect2>
    <title>なぜ SGML なのか?<!-- Why SGML? --></title>
    <subtitle>簡単な歴史<!-- A very brief history --></subtitle>
    <para>一般に信じられているのとは違って SGML (XML の父)は非常に古い原語であり、中には、かつて多くのコンピュータエンスーが
    20 年前に SGML のようなオープンな標準を押し進め、しかし市場によって無視され、あるいは商業的な意図から存在を隠されてきたことを
    ふまえて、それを ``四十年来の復讐''[the fourty'ers って何?]と読んでいる人さえいます。いずれにせよ、SGML は重要な企業、産業界で
    何年も使われています。実際、多くの巨大で重要な企業は長いこと企業情報を SGML として保存しています。
      <!-- Contrary to popular belief SGML (the father of XML) is a very
      old language, and some even have called it ``the revenge of
      the fourty'ers'', meaning that there were many computer
      enthusiasts that were pushing for open standards like SGML 20
      years ago and were ignored by the market, or perhaps hidden
      from the market by commercial interests. In any case, SGML has
      been in use for many years by very important companies and
      industries. In fact, many large and important corporations
      have kept their corporate knowledge in SGML for a long
      time now. -->
    </para>
    <para>次は SGML の歴史を知るのに良いリンクです:
      <!-- Here is a good link for the history of SGML: -->
    </para>
    <para>
      <ulink
	url="http://xml.coverpages.org/general.html#faq">
	http://xml.coverpages.org/general.html#faq
      </ulink>
    </para>
    <para>XML は単に SGML の単純化されたサブセットであり、すなわち任意の XML 文書は妥当な SGML ですが逆は真ではありません。
    XML は最近押し進めらてきていますが、基本的には 90年代に web の爆発的に普及した HTML
      <!-- XML is just a simplified subset of SGML, meaning that any XML
      document is a valid SGML, but not necessarily the
      opposite. XML has been pushed recently, basically as a way of
      pushing through the roof that HTML -->
      <footnote>
	<para>"HTML は実際には SGML の実装の一つです。SGML 実装とは DTD (文書型定義;
	基本的にはタグの名前とパラメータ、出現する順番、そして入れ子のルールなどを記述する)と
	呼ばれるものでなります。SGML 実装であるマークアップ言語は数多くありますが、最近のほんの数年ばかりで XML の創生に伴う
	より多くの標準化の動きが台頭してきています。SGML の素晴しい点は、任意の文書を簡単に他の任意の形式に、単に宣言型の
	変換シートを定義するだけで(すなわち、手続きプログラミングなしで!)変換できるということです。"
	  <!-- HTML is actually an implementation of SGML. SGML
	  implementations are called DTDs (Document Type
	  Definitions) and basically describe the names and
	  parameters of the tags, the order of occurrence, and the
	  nesting rules. There are many mark-up languages that are
	  implementations of SGML, and with the creation of XML many
	  more standards have arisen in just a few years. The magic
	  of SGML is that any document can be easily transformed
	  into any other format just by defining a declarative
	  transformation sheet (i.e. requires no procedural
	  programming!). -->
	</para>
      </footnote>の上位、後にくるものとしてとらえられています。これら言語の話についてはウェブ上のいたるところでみつけることができるので
      詳細についてはここではふれないでおきます。とにかく、この文書の残りの部分で私は SGML について言及するつもりですが、
      おそらく XML も大体同じであり、単により単純になっただけだとわかるでしょう。SGML と XML の間にはその変換に関する部分で大きな違いが
      あります。SGML では Lisp の方言の一つ、Scheme で書かれた DSSSL スタイルシートを使います。[一方、]XML ではより記述と保守を大幅に
      簡便にするために XML で記述された XSLT というより単純な変換のための標準が開発されてきました。これはこの文書の焦点ではないので、
      Eric  Raymond の非常に優れた記事を参照することをお勧めします:
      <!-- has set after the explosion of the web in the 90's. Stories of
      these languages can be found all over the web so I won't go
      into that detail here. Anyway, in the rest of this document I
      will be referring to SGML but up to this point you probably
      figured out that XML is the same thing, just simpler. There
      are some major distinctions between SGML and XML when it comes
      to transformation. SGML uses DSSSL style sheets that are
      written in Scheme a dialect of Lisp. XML has developed a
      simpler standard of transformation called XSLT which is
      written in XML making it a lot easier to write and
      maintain. Since none of this is the focus of this document I
      recommend the interested to visit Eric Raymond's excellent
      article: -->
    </para>
    <para>
      <ulink
	url="http://www.tldp.org/HOWTO/DocBook-Demystification-HOWTO/">
	http://www.tldp.org/HOWTO/DocBook-Demystification-HOWTO/
      </ulink>
    </para>
    <para>最後に、この節の題目で示された疑問に対する答えとしては、主に、SGML (または XML)は拡張可能な言語であり
    他の標準が使えるようになったとしても容易に変換できるので良い考えだということです。これはもし文書を SGML 形式で記述し、
    保守すればそれらは技術や標準が変化しても生き抜くことができ、簡単に他の任意の標準へ変換できるので安心であるということを
    意味しています。さらに言うと、SGML は古く安定な ISO 8879:1986 標準です。
      <!-- Finally, and to answer the question implied in the title of
      this section, SGML (or XML) is a good idea mainly because it's
      an extensible language that can be easily transformed into
      other standards when they become available. This means that if
      you write or keep your documents in SGML, you are assured that
      they will survive any changes in technology or standards and
      can be easily transformed into any other
      standard. Furthermore, SGML is an old and stable ISO
      8879:1986. -->
    </para>
  </sect2>
  <sect2>
    <title>SGML in a Nutshell</title>
    <para>SGML は Standard Generalized Mark-up Language (標準汎用マークアップ言語)の略記です。一方、XML は eXtensible Mark-up Language
    (拡張可能なマークアップ言語)の略記であり、単に単純化された SGML のサブセット(実装ではありません。前節を参照のこと)です。
    コンピュータ言語の一種ですが、手続き型ではなく(すなわち、命令はその並び順で実行されたりはしません)、むしろ宣言的な言語です。
      <!-- SGML stands for Standard Generalized Mark-up Language. By the
      way, XML stands for eXtensible Mark-up Language and it's just a
      simplified subset of SGML (not an implementation of, see
      previous section). It's a computer language, but it's not a
      procedural language (i.e. the instructions do not get executed
      in any specific order), but rather a declarative language. -->
    </para>
    <para>マークアップ言語は&lt;タグ&gt;の利用を基礎に置いています。タグはデータベースのように構造を定義し、
    SGML 用語集の中で言及されているようにタグ以外のすべては内容か文字データ(CDATA)です。標準としての SGML は
    使用上の基本的なルールとタグの入れ子関係を定義するだけです。例えば、すべてのタグは終端タグを持たなければ
    ならず、その入れ子は完全でなければならない、ようするに入れ子の(内側の)タグは外側のものより先に閉じなければ
    ならないということを言っています。もちろん SGML 定義はもっとずっと複雑ですが、これらが基本となるルールです。
    XML は単純化された SGML のサブセットであり、タグの開始、終了については非常に厳格です。例外的なタグとして
    終了タグを持たないものがあり、&lt;タグ /&gt; という形式です
    <footnote><para>これは実は対となるタグの間に挟む要素がない場合の単なる短縮表記(空タグ)です。</para></footnote>。
    またタグは HTML の <sgmltag>BODY</sgmltag>タグでページの背景色をパラメータ<parameter>BGCOLOR="WHITE"</parameter>で指定できるように
    パラメータを持つこともできます。
      <!-- Mark-up languages are based on the use of the &lt;tag>. The tag
      defines the structure, much like a database, and everything
      else is content, or character data (aka CDATA) as it is
      referred in the SGML jargon. SGML as a standard only defines
      basic rules on the use and nesting of tags. For example, it
      states that all tags must have an end tag, and that nesting
      should be perfect, which simply means that nested (inner) tags
      must be closed before the outer ones. Of course, the SGML
      definition is a lot more complex, but those are the basic
      rules. XML is a simplified subset of SGML, and it's very strict
      on the opening and closing of tags. There are exceptional tags
      that do not have closing tags and are of the format
      &lt;tag/>. Tags may also have parameters like the
      <sgmltag>BODY</sgmltag> tag in HTML where you can specify the
      background color of page with the parameter
      <parameter>BGCOLOR="WHITE"</parameter>. -->
    </para>
    <para>これらの基本ルールを与えられると残りのすべてはユーザーに託されます。これはつまりタグの名前、パラメータ、そして実装依存の
    入れ子のルールは SGML で記述者がつくることができるということです。これが SGML の美しさであり、誰もが自身のタグ標準を創造できる
    ようにしています。これを考慮すると、実際には SGML は、標準かつ、パーザーと呼ばれる既成のツールによって簡単に操作したり
    変換したりできる柔軟なデータ構造を記述するための言語です。SGML データ構造は RDBMS (SQL)テーブルよりもずっと柔軟であり、
    本のような複雑なものも保持でき、しかし本や文書に限定されるものでもありません。実際、SGML と今の XML は多くの旧式の
    オブジェクト指向の DBMS 実装が行ってきた汎用のデータベースストレージとしても使われています。
      <!-- Given these basic rules, everything else is left up to the
      user. This means that the name of the tags, their parameters,
      and implementation-specific nesting rules can me made up by
      the person writing in SGML. This is the beauty of SGML, it
      lets anyone invent their own tag standard. If you think of
      it, SGML is actually a language to describe flexible data
      structures that are easily manipulated and transformed by
      standard off-the-shelf tools called parsers. SGML data
      structures are far more flexible that RDBMS (aka SQL) tables,
      for storing complex things like books, but are not limited to
      books and documentation. In fact, SGML and now XML is used for
      general purpose database storage doing away with many legacy
      Object-Relational DBMS implementations. -->
    </para>
    <para>さあ、誰でも独自のマークアップ言語を SGML でつくれるなら、あなたの発明したルールを強制する方法がなければなりません。
    これが DTD (文書型定義)と呼ばれるものです。DTD は SGML 実装のためのタグの名前、パラメータ、発現する順番、入れ子のルールを
    定義します。DTD もまた SGML で記述され、システム上の他のファイルとなっているだけです。DocBook は DTD であり、
    <emphasis>book</emphasis> と <emphasis>article</emphasis>などを定義するのに使われています。
      <!-- Now, if anyone can make up their own mark-up language with
      SGML, there must be a way to enforce the rules you
      invented. This is called a DTD (Document Type Definition). A
      DTD defines the tag names, their parameters, the legal order
      of occurrence, and the nesting rules for a particular SGML
      implementation. A DTD is also written in SGML and it's just
      another file in the system. Docbook is a DTD that is used to
      define <emphasis>books</emphasis> and
      <emphasis>articles</emphasis>. -->
    </para>
    <para>DTD は様々な方法で強制されています。第一に文書の筆者によって、つまり、その形式で書こうとする前にその
    DTD についてその人はいくつか重要な点について知っているべきです。また文脈上の妥当性検証の能力を持つ構造化エディタを使うことも
    できます。これらのエディタは文書内の任意の個所で挿入できるタグを示してくれます。さらには、システム上の DTD に対してあなたの
    文書が妥当なものかどうかパーザにかけて検証できますし、もし何らかの矛盾点があれば警告してくれるでしょう。
      <!-- DTDs are enforced in various ways. First by the person writing
      the document, I mean, the person should have some prior
      knowledge on the DTD before starting to write in that
      format. Also, you could use a structured editor that has the
      capability of contextual validation. These editors help you by
      indicating the tags you are allowed to insert at any point in
      the document. Furthermore, you can use a validating parser that
      will check your document against a DTD in the system and will
      alert you of any inconsistencies. -->
    </para>
    <para>OK、SGML をはじめるにあたって知っておくべき基本的なことについてはこれですべてです。これらのコンセプトすべてに
    ついては次節に進んで Emacs で SGML を作成するようになるとずっと明らかになることでしょう。
      <!-- OK, so that's basically everything you need to know to start
      working with SGML. All these concepts will become a lot
      clearer as we move to the next section to create a SGML using
      Emacs. -->
    </para>
  </sect2>
</sect1>

<!-- vim: sw=2 sts=2 ai si sm :
-->

