DSSSL スタイル言語によるスクリプト記述によって、どのようにSGML文書にスタイルを指定していくかという過程を見ていきましょう。
サンプルとして以下のSGML 文書を用います。
サンプルとして以下のSGML 文書を用います。
<!DOCTYPE example [ <!ELEMENT example - - (head,text)> <!ELEMENT head - - (#PCDATA)> <!ELEMENT text - - (section+)> <!ELEMENT section - - (subhead,para+)> <!ELEMENT subhead - - (#PCDATA)> <!ELEMENT para - - (#PCDATA)> ] > <example> <head>Chicago Rule</head> <text> <section> <subhead>Subheads</subhead> <para>The typeface and type size used for all subheads are ideally the same as those used for the text. Differentiation of levels is brought about by various combinations of the available five-alphabet font and by placement on the page.</para> </section> <section> <subhead>Justification</subhead> <para>A column type is convenionally rectangular, its left and rightedges neatly aligned. To make a line of type, regardless of the words in it, exactly the same length as its fellows is to justify the line. This is still common practice in bookmaking. Since words in a language, unlike bricks in a building, are not all the same length, and since a word should not be devided at the end of a line without regard for the rules of word division, the spacing between words in justified lines cannot be exactly the same in each line.</para> </section> <section> <subhead>Spacing</subhead> <para>Spacing between printed words is partly a matter of the mechanics of composition. “Normal” word spacing is about one-third of an em. But when lines of type are justified---each line the same length---spacing between words will vary slightly from line to line, though all word spacing in a single line should be the same.</para> <para>In display matter (title pages, chapter headings, etc.) and in anything set in full caps or caps and small caps, letterspacing--- additional space between letters---is often specfied by the designer.</para> <para>The space between lines of type is called leading, or a lead, because in hand or Monotype composition it was originally created by strips of lead insertedbetween lines of type.</para> </section> <section> <subhead>Indent</subhead> <para>There are two indent styles, paragraph style and flush-and-hang style. Paragraph style indent is represetned by “first-line-start-indent:” characteristic. Flush-and-hang style indent is represented by “first-linestart- indent:” and“start-indent:” characteristics.</para> </section> </text> </example>
グローブ構造は以下のようになります。
このSGML文書を以下のスタイル言語スクリプトによってフォーマット処理することにします。
<!DOCTYPE style-sheet system “style-sheet2.dtd”> <style-sheet> <style-specification> <style-specification-body> (define *a4-width* 210mm) (define *a4-height* 297mm) (define *a3-width* 297mm) (define *a3-height* 420mm) (define *b4-width* 257mm) (define *b4-height* 364mm) (element example (make simple-page-sequence ;ページの大きさ。A4 に設定。 page-width: *a4-width* page-height: *a4-height* ;各マージン。上下左右とも3cmに設定。 top-margin: 3cm bottom-margin: 3cm left-margin: 3cm right-margin: 3cm)) (element head (make paragraph ;スペースの設定。前に40pt,後ろに24pt のスペースをとる。 space-before: 40pt space-after: 24pt ;fontの設定。”Helvetica”,24pt,bold に設定。 font-family-name:"Helvetica" font-size: 24pt font-weight: 'bold ;行間36ptに設定。 line-spacing: 36pt ;行揃えを行の先頭に設定。 quadding: 'start)) (element subhead (make paragraph keep-with-next?: #t space-before: 10pt space-after: 5pt font-family-name:"Helvetica" font-size: 16pt font-weight: 'bold line-spacing: 24pt quadding: 'start ;section番号に“.”をつけて返す (let ((section-num (child-number (parent (current-node))))) (literal (number->string section-num) “.”)) (process-children))) (define *paragraph-style* ; 段落のスタイルを定義 (style font-family-name:"Times Roman" font-size: 12pt font-weight: 'medium line-spacing: 18pt quadding: 'justify)) (element para (if (first-sibling? (current-node)) ; 見出しの次の段落なら字下げなし (make paragraph use: *paragraph-style*) ; それ以外の段落は、第1行を字下げする (make paragraph use: *paragraph-style* first-line-start-indent: 12pt))) </style-specification-body> </style-specification> </style-sheet>
これを実際に出力した結果は次のようになります。