4

XHTML / hResumeドキュメントをプレーンテキストに変換するXSLテンプレートに取り組んでいますが、テーブルのレイアウトに問題があります(いいえ、レイアウトテーブルではありません)。現時点では、優れたDave Pawsonのパディングテンプレートを使用して、次のものを入手しています。

<variable name="newline" select="'&#10;'"/>
<template match="xhtml:table">
    <variable name="maxWidth">
        <for-each select="xhtml:tr/xhtml:th | xhtml:tr/xhtml:td">
            <sort select="string-length(child::text()|child::node())" order="descending" data-type="number"/>
            <if test="position() = 1">
                <value-of select="string-length(child::text()|child::node())"/>
            </if>
        </for-each>
    </variable>
    <for-each select="xhtml:tr">
        <for-each select="xhtml:th|xhtml:td">
            <variable name="string">
                <for-each select="child::text()|child::node()">
                    <value-of select="."/>
                </for-each>
            </variable>
            <value-of select="$string"/>
            <call-template name="append-pad">
                <with-param name="length" select="$maxWidth - string-length($string)"/>
            </call-template>
            <text>&#32;</text>
        </for-each>
        <value-of select="$newline"/>
    </for-each>
    <value-of select="$newline"/>
</template>

これにより、同じ幅の列が生成されますが、いくつかの方法で改善したいと思います。

  • 各列の最大幅を見つけて使用します。そのためには、柔軟な数の値を格納する必要があります。単純なケースでこれを行うためにmaxWidthを変更できますが、スパン列をどのように処理しますか?
  • スパン列の内容を中央に配置します。

このようなことをするためのテンプレートはありますか?

4

1 に答える 1