0

XSLT を使用して XML 構造を FO スクリプトに変換しようとしています。番号付きの見出しに問題があります。私は次のようなXML構造を持っています:

<?xml version="1.0"?>
<document>
   <type1>
      <heading>Topic level1</heading>
      <paragraph>Text</paragraph>
   </type1>
   <type2>
      <heading>Topic level1</heading>
      <paragraph>Text</paragraph>
   </type2>
   <type1>
      <heading>Topic level1</heading>
      <type1>
         <heading>Topic level2</heading>
         <paragraph>Text</paragraph>
         </type1>
           <heading>Topic level3</heading>
           <paragraph>Text</paragraph>
         </type1>
      </type1>
   </type1>
...
</document>

元の XML 構造はより深くネストされており、より多くの要素があります。現在、次のようなテンプレートがあります。

<xsl:template match="type1/heading | type2/heading | type3/heading | type4/heading | 
 type5/heading | type6/heading | type7/heading">
   <fo:block font-weight="bold" font-size="13pt" space-after="5mm" id="{generate-
   Id()}">
      <xsl:number count="type1| type2| type3| type4| type5| type6 | type7"
       format="1.1" level="multiple"/>&#160;
      <xsl:apply-templates/>
   </fo:block>
</xsl:template>

出力は基本的にOKです。ただし、すべての見出しのスタイル パラメータは同じです。見出しレベルごとに異なるスタイルを設定したいと考えています。たとえば、次のようにします。

1.トピックレベル1

文章

2.トピックレベル1

文章

3.トピックレベル1

文章

3.1 トピックレベル2

文章

3.1.1 トピックレベル3

文章

どうやってやるの?

4

1 に答える 1

0

の結果のドット<xsl:number>数または type1 | の先祖の数を数えることで、現在の見出しのレベルを判断できます。type2 など

于 2014-08-22T23:06:32.573 に答える