2017-03-21 17 views
0

XML:表XSL-FO XSLT 1.0

<levelledPara><title>Tools List and Tool Illustrations</title> 
<levelledPara><title>General</title> 
<levelledPara><para>The special tools, fixtures, and equipment needed.</para></levelledPara></levelledPara> 

XSLT:

<xsl:template match="levelledPara" name="levelledPara" mode="tocdm"> 
    <xsl:if test="*[self::title] and not(parent::*[self::levelledPara])"> 
     <xsl:variable name="id"> 
      <xsl:call-template name="para.id"/> 
     </xsl:variable> 
    <fo:table-row> 
     <fo:table-cell xsl:use-attribute-sets="table.cell.padding1" number-columns-spanned="2"> 
      <fo:block text-transform="capitalize" text-align-last="justify" text-indent="21mm"> 
          <xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/> 
          <xsl:text>&#160;&#160; </xsl:text> 
       <xsl:value-of select="title" /><fo:leader leader-pattern="dots"/><fo:basic-link internal-destination="{$id}"><fo:page-number-citation ref-id="{$id}"/></fo:basic-link> 

      </fo:block> 
     </fo:table-cell> 
    </fo:table-row> 
    </xsl:if> 
</xsl:template> 

<xsl:template match="levelledPara"> 
     <fo:list-block 
      provisional-distance-between-starts="21mm" 
      provisional-label-separation="4pt"> 
      <fo:list-item space-after="8pt" space-before="13pt" start-indent="0pt">    
        <xsl:variable name="id"> 
         <xsl:if test="*[self::title] and not(parent::*[self::levelledPara])"> 
<xsl:call-template name="para.id"/> 
         </xsl:if> 
        </xsl:variable> 
       <fo:list-item-label 
        end-indent="label-end()" 
        text-align="start"> 

        <fo:block font-weight="bold" id="{$id}">     
         <xsl:if test="not(./table)"> 
            <xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/> 
           </xsl:if> 
        </fo:block> 
       </fo:list-item-label> 
       <fo:list-item-body 
        start-indent="body-start()"> 
        <xsl:apply-templates/> 
       </fo:list-item-body> 
      </fo:list-item> 
     </fo:list-block> 
    </xsl:template> 

<xsl:template name="para.id"> 
    <xsl:param name="object" select="."/> 
    <xsl:apply-templates select="ancestor::dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/> 
    <xsl:choose> 
    <xsl:when test="$object/@id"> 
      <xsl:value-of select="$object/@id"/> 
    </xsl:when> 
    <xsl:otherwise> 
     <xsl:value-of select="concat(count(ancestor::node()),'00000000',count(preceding::node()))"/> 
    </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 

第標題levelledParaが目次に含まれるべきです。私のサンプルマークアップにはIDがありません。 levelledParaのfo:blockにidを割り当てるのを忘れたため、ページ番号が解決されませんでした。

+0

あなたも 'のターゲットであるFOに' id'プロパティを設定したテンプレートを表示することができますfo:page-number-citation'? –

+0

AH Formatterからのエラーメッセージはありますか? –

+0

ああ、私はそれが問題だと思う、私は決してFOのブロック上のIDを設定します。私が得ているエラーは、未解決のiD値とそれに対応する未解決の内部デスティネーションです。 – Caroline

答えて

0

目次にはXSLTが表示されています。 TOCのIDは、文書のメインテキストのIDと一致する必要があります。

だから、テンプレートマッチが=「levelledParaは」IDを設定し、ブロックが含まれている必要があります。

<xsl:variable name="lpcode"><xsl:value-of select="$dmcode" /><xsl:value-of select="generate-id(.)" /></xsl:variable> 
<fo:block id="{$lpcode}"> 
+0

それは働いた、ホッブズ、ありがとう、私は上記のコードを修正しました。 – Caroline