この文書は、 Daniel M. Germán 氏が http://csgrs6k1.uwaterloo.ca/‾dmg/dsssl/tutorial/tutorial.html で公開している "An Introduction to DSSSL" を翻訳したものです。
日本語版に関するお問い合わせは, 佐藤 (<hrs@eos.ocn.ne.jp>) までお知らせください.
このチュートリアルは, Jon Bosak 氏と匿名の人物によって投稿された play.dsl というスタイルシートに基づいたものです. どちらかと言うと単純さを優先していて, あまり詳しく解説しているものではありませんが, 理解するのが困難なものではないと思います.
Paul Prescod 氏による, もう一つのチュートリアルが http://itrc.uwaterloo.ca/‾papresco/dsssl/tutorial.html にあります. このチュートリアルはさらに細かい部分も書かれており, Scheme の知識を前提としていません.
このチュートリアルの目的は DSSSL の基礎を紹介することです. ここでわたしたちは, (Jon Bosak 氏が投稿した play.dsl を元に) 演劇の台本用の DSSSL スタイルシートを作成していきます.
例のコピーは, 次の場所からダウンロードできます.
さて, わたしたちは既に SGML ファイルと DTD を入手しています. 最初のステップは, 演劇の台本テキストを組版しないで RTF ファイルとして出力することです.
; This dumps the text of the plays without any particular format ; (訳: これは演劇の台本を組版しないで出力するものです) (root (make simple-page-sequence (process-children)) )
得られる RTF ファイルは単に文字が並んでいるだけで, 余白や段落はまったくありません. また, フォントファミリ, フォントサイズ, ページサイズなどは Jade のデフォルト値が使われています.
(root
(make simple-page-sequence
; margins
; (訳: 余白)
left-margin: 1in
right-margin: 1in
top-margin: 1in
bottom-margin: 1in
(process-children))
)
次に, SGML に現れるエレメントに一つずつ, 書式を追加して行きましょう.
(element (PLAY TITLE) ;the play's title
(make paragraph
quadding: 'center
font-size: 18pt
line-spacing: 18pt
font-weight: 'bold
keep-with-next?: #t
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Front matter
;
(element (FM)
(make paragraph
font-size: 8pt
line-spacing: 8pt
; left and right indentation
start-indent: 5cm
end-indent: 5cm
; space before
space-before: .5cm
; space after
space-after: .5cm
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Adding constants
(define *titleFontSize* 18pt)
(define *fmFontSize* (/ *titleFontSize* 2))
(define *fmIndent* 3cm)
(define *fmSpaceBefore* .5cm)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; TITLE of the PLAY
(element (PLAY TITLE)
(make paragraph
quadding: 'center
font-size: *titleFontSize*
line-spacing: *titleFontSize*
font-weight: 'bold
keep-with-next?: #t
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Front matter
;
(element (FM)
(make paragraph
font-size: *fmFontSize*
line-spacing: *fmFontSize*
; left and right indentation
start-indent: *fmIndent*
end-indent: *fmIndent*
; space before
space-before: *fmSpaceBefore*
; space after
space-after: *fmSpaceBefore*
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PERSONAE
(element PERSONAE
(process-children))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PERSONA
(element PERSONA ;a person
(make paragraph
space-before: *personaSpaceBefore*
start-indent: *personaIndent*
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; TITLE inside PERSONAE
(element (PERSONAE TITLE)
(make paragraph
font-size: *personaetitleFontSize*
line-spacing: *personaetitleFontSize*
font-weight: 'bold
keep-with-next?: #t
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PGROUP
; We have to extract the description of the group (located
; at the end of the PGROUP, and displayed at _the beginning_
(define (*groupName*)
; First set x to GRPDESCR content
(let ((x
(data (select-elements (children (if (equal? (gi) "PGROUP")
(current-node)
(ancestor "PGROUP")))
'(GRPDESCR))))
)
; if x ends in "." drop the latter. then concatenate ":"
(string-append
(if (string=?
(substring x (- (string-length x) 1) (string-length x))
".")
(substring x 0 (- (string-length x) 1))
x)
":"
)
)
)
(element PGROUP
(make paragraph
start-indent: *personaIndent*
space-before: *textSpaceBefore*
font-weight: 'bold
(literal (*groupName*))
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PERSONA inside a PGROUP
(element (PGROUP PERSONA )
(make paragraph
space-before: *personaSpaceBefore*
start-indent: *pgroupIndent*
font-weight: #f
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GRPDESCR
; it has been extracted, so ignore
(element GRPDESCR
(empty-sosofo))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Scndescr
(define *sceneStyle* ;style for all scene descriptions
(style
quadding: 'center
font-size: (+ *textFontSize* 4pt)
line-spacing: *textFontSize*
font-weight: #f
font-posture: 'italic
start-indent: *sceneIndent*
end-indent: *sceneIndent*))
(element SCNDESCR
(make paragraph
use: *sceneStyle*
space-before: *sceneSpaceBefore*
(process-children)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; STAGEDIR
;
(element STAGEDIR
(make paragraph
font-posture: 'italic
; If it is inside a line or speech, don't put space-before, otherwise
; skip some space
space-before: (if (or (equal? (gi (parent)) "LINE")
(equal? (gi (parent)) "SPEECH"))
0pt
*textFontSize*)
; surround so not spoken accidentally
(literal "[")
(process-children)
(literal "]")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SPEECH
(element SPEECH ;a set of lines by one or more speakers
(make table ;use a table to accommodate multiple speakers
space-before: (/ *textFontSize* 2)
may-violate-keep-after?: #t
(make table-column ;ensure speaker column is narrow
column-number: 1
width: *speakerWidth*)
(make table-cell ;collect all speakers
(make paragraph
(with-mode *speechSpeaker*
(process-matching-children "SPEAKER"))))
(make table-cell ;collect all lines and instructions
(process-children))))
(mode *speechSpeaker* ;collect all speakers into single column
(element SPEAKER ;separate with ampersands to indicate multiple
(if (= (child-number) 1)
(make sequence
font-posture: 'italic
(process-children))
(make sequence
font-posture: 'italic
(literal " & ")
(process-children))))
(default ;fail-safe - this should not trigger
(empty-sosofo)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SPEAKER
; This has been taken care of in speechSpeaker mode, therefore ignore in
; normal mode
(element SPEAKER ;this should not trigger - only in mode
(empty-sosofo))
(element LINE ;all of the lines for a given set of speakers
(make paragraph
(process-children)))
DSSSL は複雑な言語です. 今までの説明は, この言語の特徴について, ほんの少し概説したに過ぎません. このチュートリアルが理解できたからと言って, DSSSL のエキスパートになれたと思い込まないでください. 「DSSSL では何が可能なのか」については, ここまでの解説で感じとってもらえたと思います. またこれが, DSSSL 規格の草稿を読み, 理解を深めるきっかけとなればと思います.
Good luck!
このチュートリアルに関するご意見がありましたら, dmg@csg.uwaterloo.ca まで遠慮なくお知らせください.