AH Formatter / XSL Formatter
Q&A



XSLT/XSL-FO/MathML テクニック

空白

トップ
基本・一般
AH Formatter について
XSL Formatter について
操作方法
プログラミング
XSLT/XSL-FO/SVG/MathML 仕様について
XSLT/XSL-FO/MathML テクニック
索引
Q.  <fo:block white-space-collapse="false">&#x0020;</fo:block> のように fo:blockwhite-space-collapse="false" を指定しました。しかし、空白行は生成されず、行頭の空白(U+0020)は削除されてしまいます。 空白行の生成や行頭の空白を残すにはどうしたらいいですか。 [No.2003101601]
A. 

行頭および行末の空白の扱いについては、V2/V3.0/V3.1R1 と V3.1MR1 とで扱いが異なります。

V2/V3.0/V3.1R1 における行頭および行末の空白の扱いについては、suppress-at-line-break プロパティで指定されます。

7.16.3 "suppress-at-line-break"

suppress-at-line-break の初期値は "auto" です。このとき、U+0020 は "suppress" が指定されたものとして扱われます。 結果として、エリアは生成されません。

行頭/行末の空白を残すには、以下のように usage-context-of-suppress-at-line-break="ignore" を 指定してください。

<fo:block white-space-collapse="false" usage-context-of-suppress-at-line-break="ignore">
     &#x0020;
</fo:block>

usage-context-of-suppress-at-line-break (UCSLB) は、Errata in REC-xsl-20011015で定義されました。

現在の XSL 1.0 Errata は suppress-at-linebreakwhite-space-treatment の仕様が変更され、usage-context-of-suppress-at-line-break は廃止されました。当時は以下の仕様が定義されていました。

7.16.4 "usage-context-of-suppress-at-line-break"

XSL Definition:

Value: auto | observe | ignore | inherit
Initial: auto
Applies to: fo:block, fo:inline, fo:page-number, fo:page-number-citation
Inherited: yes
Percentages: N/A
Media: visual

This property specifies the usage context of the character property "suppress-at-line-break". It specifies if this character property should apply or not.

Values for this property have the following meanings:

auto
If the value of the "wrap-option" trait on the current formatting object to which the "usage-context-of-suppress-at-line-break" applies is "no-wrap", the "auto" value specifies the same processing of descendant fo:character formatting objects as if "ignore" had been specified for the "usage-context-of-suppress-at-line-break" property. Otherwise it specifies the same processing of descendant fo:character formatting objects as if "observe" had been specified for the "usage-context-of-suppress-at-line-break" property.

observe
Specifies that descendant fo:character formatting objects should be treated using the computed value of the "suppress-at-line-break" property of the fo:character formatting object.

ignore
Specifies that descendant fo:character formatting objects should be treated as if the "suppress-at-line-break" property of the fo:character formatting object had the value "retain".

これにより、suppress-at-line-break (SLB) プロパティは以下のように制御されます。

wrap-option
wrap (initial) no-wrap
SLB SLB
auto suppress retain auto suppress retain
U
C
S
L
B
auto D D R R R R
observe D D R D D R
ignore R R R R R R
R: 空白は残ります
D: 空白は削除されます

XSL Formatter では suppress-at-line-break が未実装のため、初期値 "auto" の処理を行います。
しかし実装された場合でも、このプロパティの適用対象は fo:character であり、継承されないので、fo:block に指定することができません。 したがって、以下のように明示的に fo:character を使って指定する必要があります。

<fo:block>
    <fo:character character="' '" suppress-at-line-break="retain"/>
</fo:block>

XSL Formatter は usage-context-of-suppress-at-line-break を実装しています。 usage-context-of-suppress-at-line-break="ignore" とすると、 suppress-at-line-break="auto" による空白除去は起きなくなります。

XSL Formatter V3.1MR1 以降では、最新の XSL 1.0 Errata と XSL 1.1 WD の仕様に適合するように、 white-space-treatment および suppress-at-line-break の処理を変更しました。行頭行末の空白を残すためには white-space-treatment="preserve" を指定すればよいようになりました。 usage-context-of-suppress-at-line-break は互換のために残していますが、その値が auto の場合の動作は observe と同じです。(以前は auto のとき wrap-option="no-wrap" ならば ignore として扱われました)もし、usage-context-of-suppress-at-line-break="ignore" が指定されていれば、以前と同様に行頭行末の空白を残します。


Copyright © 1999-2011 Antenna House, Inc. All rights reserved.
Antenna House is a trademark of Antenna House, Inc.