2016-12-07 12 views
1

Apache FOPウェブアプリケーションからPDFを生成するには、CKEditorを使用してリッチテキストを編集できます。XSL:FOレベルごとに異なるリスト項目ラベル

私の問題は、ユーザーが時々リストを命じた(未)でインデントの異なるレベルを使用することで、例えば:

  • リストアイテムレベル1
    • リストアイテムレベル2

CKEditorは、レベル(またはインデント)ごとに異なる掲示を表示しますが、テンプレートは次のように見えるため、生成されたPDFは表示されません。

<!-- Lists --> 
<xsl:template match="ul|ol" mode="content"> 
    <xsl:apply-templates select="li" mode="content"> 
     <xsl:with-param name="ordered"> 
      <xsl:value-of select="name()='ol'"/> 
     </xsl:with-param> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="li" mode="content"> 
    <xsl:param name="ordered"/> 
    <xsl:variable name="label"> 
     <xsl:choose> 
      <xsl:when test="$ordered='true'"> 
       <xsl:value-of select="position()"/> 
       . 
      </xsl:when> 
      <xsl:otherwise> 
       &#8226; 
      </xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <fo:list-block padding-bottom="0pt"> 
     <fo:list-item> 
      <fo:list-item-label> 
       <fo:block> 
        <xsl:value-of select="$label"/> 
       </fo:block> 
      </fo:list-item-label> 
      <fo:list-item-body start-indent="body-start()"> 
       <fo:block> 
        <xsl:apply-templates mode="content"/> 
       </fo:block> 
      </fo:list-item-body> 
     </fo:list-item> 
    </fo:list-block> 
</xsl:template> 

どのようにインデントのレベルに応じてラベル変数を設定できますか?

のような何か:

  • 1レベル:&#8226
  • 第二レベル:&#9702
  • 第三レベル:事前に&#8269

おかげで、〜ファビ

編集:解決策は@ FAFLは、次のようになります。「UL |オール」の各再帰呼び出し1.のデフォルト値との両方のテンプレートにパラメータ「深さ」を追加

<!-- Lists --> 
    <xsl:template match="ul|ol" mode="content"> 
     <xsl:param name="depth" select="0"/> 
     <xsl:apply-templates select="li" mode="content"> 
      <xsl:with-param name="ordered"> 
       <xsl:value-of select="name()='ol'"/> 
      </xsl:with-param> 
      <xsl:with-param name="depth"> 
       <xsl:value-of select="$depth + 1"/> 
      </xsl:with-param> 
     </xsl:apply-templates> 
    </xsl:template> 

    <xsl:template match="li" mode="content"> 
     <xsl:param name="depth" select="0"/> 
     <xsl:param name="ordered"/> 
     <xsl:variable name="label"> 
      <xsl:choose> 
       <xsl:when test="$ordered='true'"> 
        <xsl:value-of select="position()"/> 
        . 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:choose> 
         <xsl:when test="$depth = 1"> 
          &#8226; <!--filled circle--> 
         </xsl:when> 
         <xsl:when test="$depth = 2"> 
          &#9702; <!--not-filled circle--> 
         </xsl:when> 
         <xsl:otherwise> 
          &#9632; <!--black square --> 
         </xsl:otherwise> 
        </xsl:choose> 
       </xsl:otherwise> 
      </xsl:choose> 
     </xsl:variable> 
     <fo:list-block padding-bottom="0pt"> 
      <fo:list-item> 
       <fo:list-item-label> 
        <fo:block> 
         <xsl:value-of select="$label"/> 
        </fo:block> 
       </fo:list-item-label> 
       <fo:list-item-body start-indent="body-start()"> 
        <fo:block> 
         <xsl:apply-templates mode="content"> 
          <xsl:with-param name="depth"> 
           <xsl:value-of select="$depth"/> 
          </xsl:with-param> 
         </xsl:apply-templates> 
        </fo:block> 
       </fo:list-item-body> 
      </fo:list-item> 
     </fo:list-block> 
    </xsl:template> 

答えて

0

てみてください1.によってそれを増やすその後、あなたはそれを照会することができます両方のテンプレートの内側にあります。

+0

これは素晴らしい動作します。ありがとう。将来の訪問者に完成したテンプレートを追加する必要がありますか? – FeinesFabi

関連する問題