• 検索結果がありません。

3.

セル

c.

ブロック要素とインライン要素

番号なしリストを処理するテンプレート

番号なしリストのテンプレート

<xsl:param name="list-startdist-default" select="string('2em')"/>

<xsl:param name="list-gap-default" select="string('0.5em')"/>

<xsl:attribute-set name="list.item" >

<xsl:attribute name="space-before">0.4em</xsl:attribute>

<xsl:attribute name="space-after">0.4em</xsl:attribute>

<xsl:attribute name="relative-align">baseline</xsl:attribute>

</xsl:attribute-set>

<xsl:template match="ul">

<!-- ラベルの先頭と本体の先頭と距離、ラベルの終了と本体の先頭との距離を決定します. -->

<xsl:variable name="start-dist-local">

<xsl:choose>

<xsl:when test="./@startdist">

<xsl:value-of select="./@startdist"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$list-startdist-default"/>

</xsl:otherwise>

</xsl:choose>

</xsl:variable>

<xsl:variable name="gap-local">

<xsl:choose>

<xsl:when test="./@gap">

<xsl:value-of select="./@gap"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$list-gap-default"/>

</xsl:otherwise>

</xsl:choose>

</xsl:variable>

<!-- fo:list-blockを生成します. -->

<fo:list-block provisional-distance-between-starts="{$start-dist-local}"

provisional-label-separation="{$gap-local}" >

<!-- 下位のliを処理させます. -->

<xsl:apply-templates/>

</fo:list-block>

</xsl:template>

<xsl:template match="ul/li">

<fo:list-item xsl:use-attribute-sets="list.item" >

<!-- リストのラベルを生成します.-->

<!-- ラベルの終了位置はlabel-end()関数で計算させます.-->

<!-- 行頭文字はtype属性で指定します.既定値は「・」-->

<fo:list-item-label end-indent="label-end()">

<fo:block text-align="end">

<xsl:choose>

<xsl:when test="../@type='disc'">

<xsl:text></xsl:text>

</xsl:when>

<xsl:when test="../@type='circle'">

<xsl:text></xsl:text>

</xsl:when>

<xsl:when test="../@type='square'">

<xsl:text>□</xsl:text>

</xsl:when>

<xsl:when test="../@type='bsquare'">

<xsl:text>■</xsl:text>

</xsl:when>

<xsl:otherwise>

<xsl:text></xsl:text>

</xsl:otherwise>

</xsl:choose>

</fo:block>

</fo:list-item-label>

<!-- リストの本体部を生成します.-->

<!-- ラベルの開始位置はbody-start()関数で計算させます.-->

<fo:list-item-body start-indent="body-start()" text-align="justify" >

<fo:block>

<xsl:apply-templates/>

</fo:block>

</fo:list-item-body>

</fo:list-item>

</xsl:template>

行頭文字の指定

番号なしリストと番号付リストのテンプレート違いは、リストのラベル部分の処理のみです.番号 なしリストではラベルに行頭文字を配置します.行頭文字の種類は、

ul

要素の

type

属性から指定でき ます.既定値は「・」ですが、

HTML

と同じ

disc, circle, square

も指定できます.

行頭文字として画像を配置するタイプのテンプレートも作成してみました.

ul

要素の

type

属性に

img:

ファイル名」の形式で画像ファイルを指定します.

行頭文字として画像を使用するテンプレート

<!-- 行頭文字として画像を使用する場合のテンプレート-->

<xsl:template match="ul[substring(@type,1,4)='img:']/li">

<fo:list-item xsl:use-attribute-sets="list.item" >

<fo:list-item-label end-indent="label-end()">

<fo:block text-align="end">

<fo:external-graphic src="{substring-after(../@type,substring(../@type,1,4))}

" content-height="1.2em" content-width="1.2em"/>

</fo:list-item-label>

<fo:list-item-body start-indent="body-start()" text-align="justify" >

<fo:block>

<xsl:apply-templates/>

</fo:block>

</fo:list-item-body>

</fo:list-item>

</xsl:template>

番号なしリストの例

入力

XML

データ

<ul type="square">

<li>リストの種類 <ul type="disc">

<li>番号なしリスト</li>

<li>番号付リスト</li>

<li>定義型リスト</li>

</ul>

</li>

<li>表の要素 <ul>

<li>行</li>

<li></li>

<li>セル</li>

</ul>

</li>

<li>ブロック要素とインライン要素</li>

</ul>

組版結果は次のようになります

□ リストの種類

● 番号なしリスト

● 番号付リスト

● 定義型リスト

□ 表の要素

・ 行

・ 列

・ セル

□ ブロック要素とインライン要素 入力

XML

データ

<ul class="img-bullet" type="leaf">

<li>リストの種類

<ul class="img-bullet" type="star">

<li>番号なしリスト</li>

<li>番号付リスト</li>

<li>定義型リスト</li>

</ul>

</li>

<li>表の要素

<ul class="img-bullet">

<li>行</li>

<li>列</li>

<li>セル</li>

</ul>

</li>

<li>ブロック要素とインライン要素</li>

</ul>

結果は次のようになります リストの種類

番号なしリスト 番号付リスト 定義型リスト 表の要素

行 列 セル

ブロック要素とインライン要素

関連したドキュメント