2016-08-24 6 views
1

を考えると、このXML:<foは:基本的な-link>のクリック可能なリンクXSL-FO XSLTを作成していない1.0

<figure id="fig-0011"> 
<title>Removal of Shipping Kit(s)</title> 
<graphic id="fig-0011-gra-0001" infoEntityIdent="66503-00129-A-001-01"></graphic> 
</figure> 

<proceduralStep><para>Remove screw (see <internalRef internalRefId="fig-0011" internalRefTargetType="irtt01"></internalRef>) 
<proceduralStep><para>Remove two screws (10) (see <internalRef internalRefId="fig-0011-gra-0001" internalRefTargetType="irtt09"></internalRef>), 

私は数字やグラフィックスへのリンクを作成しようとしています。図へのリンクが正しく動作しているが、グラフィックへのリンクがない:キー

<fo:basic-link> 
<xsl:attribute name="internal-destination"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="@internalRefId"/></xsl:attribute> 
<xsl:variable name="targetElement" select="local-name(key('id',@internalRefId))"/> 
<xsl:for-each select="key('id',(@internalRefId))"> 
    <xsl:choose> 
     <xsl:when test="$targetElement='graphic'"> 
      <xsl:text>Fig </xsl:text> 
      <xsl:number count="figure" from="content" level="any"/> 
     </xsl:when> 
     <xsl:when test="$targetElement='figure'"> 
      <xsl:text>Fig </xsl:text> 
      <xsl:number count="figure" from="content" level="any"/> 
     </xsl:when> 
    </xsl:choose> 
</xsl:for-each> 

<xsl:key name="id" match="*" use="@id"/> 

図:

<xsl:template match="figure"> 
    <xsl:apply-templates select="graphic"/>  
</xsl:template> 

<xsl:template match="figure/graphic" priority="10"> 
    <fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always"> 
     <xsl:call-template name="do-graphic"> 
      <xsl:with-param name="include-graphic" select="true()"/> 
     </xsl:call-template> 
    </fo:block> 
    <xsl:if test="position()=last()"> 
     <xsl:apply-templates select="../legend"/> 
    </xsl:if> 
    <xsl:if test="@infoEntityIdent"> 
     <fo:block text-align="right" keep-with-previous="always"> 
      <xsl:value-of select="@infoEntityIdent"/> 
     </fo:block> 
    </xsl:if> 
    <fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always"> 
     <xsl:if test="../@id"> 
      <xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="../@id"/></xsl:attribute> 
     </xsl:if> 
     <xsl:text>Fig </xsl:text> 
     <xsl:number count="figure" level="any" format="1" from="content"/> 
     <xsl:apply-templates select="../title"/> 
     <xsl:variable name="numSheets" select="count(../graphic)"/> 
     <xsl:choose> 
      <xsl:when test="$numSheets>1"> 
       <xsl:text> (Sheet </xsl:text> 
       <xsl:number count="graphic" level="any" format="1" from="figure"/> 
       <xsl:text> of </xsl:text> 
       <xsl:value-of select="$numSheets"/> 
       <xsl:text>)</xsl:text> 
      </xsl:when> 
     </xsl:choose> 
    </fo:block> 

グラフィック:

<xsl:template match="graphic"> 
    <fo:inline-container> 
     <fo:block space-before="12pt" space-before.conditionality="retain"> 
      <xsl:call-template name="do-graphic"/> 
     </fo:block> 
    </fo:inline-container> 
</xsl:template> 

<xsl:template name="do-graphic"> 
    <xsl:param name="include-graphic" select="true()"/> 
    <xsl:variable name="content-width"> 
     <xsl:choose> 
      <xsl:when test="@reproductionWidth != ''"> 
       <xsl:value-of select="@reproductionWidth"/> 
      </xsl:when> 
      <!-- coding for reproduction scale based on clarifications in Issue 4.1 --> 
      <xsl:when test="@reproductionScale != ''"> 
       <xsl:value-of select="@reproductionScale"/> 
       <xsl:text>%</xsl:text> 
      </xsl:when> 
      <xsl:otherwise>95%</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:variable name="content-height"> 
     <xsl:choose> 
      <xsl:when test="@reproductionHeight != ''"> 
       <xsl:value-of select="@reproductionHeight"/> 
      </xsl:when> 
      <xsl:when test="@reproductionScale != ''"> 
      <xsl:value-of select="@reproductionScale"/> 
       <xsl:text>%</xsl:text> 
      </xsl:when> 
      <xsl:otherwise>95%</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:choose> 
     <xsl:when test="$include-graphic"> 
      <fo:external-graphic src="{unparsed-entity-uri(@infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}"/> 
     </xsl:when> 
     <xsl:otherwise> 
      <fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red"> 
       <fo:block>Graphic Not Included</fo:block> 
      </fo:inline-container> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 

これが返されます。

Remove two screws (10) (see Fig 2) 

正しい数字の数ですが、2は、グラフィックへのクリック可能なリンクされていません。

dmcodeテンプレートは文字列を作成します。それをXSLTから削除すると、図の番号は図にリンクしなくなります。

私はXSLT 1.0を使用しています。助けてくれてありがとう、ありがとう。

答えて

0

第2のinternalRefgraphicを指す。あなたのXSLTがgraphic/@idを結果ツリーのFOにコピーしていないようです。

Unresolved internal-destination: "fig-0011-gra-0001". 

一致するターゲットIDがないときにFOフォーマッタは、リンクを作っていないことが表示されます:AHのフォーマッタとgraphic/@idをコピーしないスタイルシートで、私は何のリンクと、エラーメッセージが表示されますありません。

私は、あなたのxsl:key宣言(複数可)を見ることなくずっとあなたを助けるfiguregraphicのテンプレート、およびgraphicfigureの外に現れることができるかどうかを知ることはできません。 figure/@idgraphic/@idを使用するために再編集し


<xsl:key name="id" match="*" use="@id" /> 

<xsl:variable name="prefix"> 
    <xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode" /> 
</xsl:variable> 

<xsl:template match="internalRef"> 
    <xsl:for-each select="key('id', @internalRefId)"> 
     <fo:basic-link internal-destination="{$prefix}{@id}"> 
      <xsl:text>Fig </xsl:text> 
      <xsl:number count="figure" from="content" level="any" /> 
     </fo:basic-link> 
    </xsl:for-each> 
</xsl:template> 

<xsl:template match="figure"> 
    <fo:wrapper id="{@id}"> 
     <xsl:apply-templates select="graphic" /> 
    </fo:wrapper>  
</xsl:template> 

<xsl:template match="figure/graphic" priority="10"> 
    <fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always"> 
     <xsl:if test="@id"> 
      <xsl:attribute name="id"> 
       <xsl:value-of select="$prefix" /> 
       <xsl:value-of select="@id" /> 
      </xsl:attribute> 
     </xsl:if> 
     <xsl:call-template name="do-graphic"> 
      <xsl:with-param name="include-graphic" select="true()" /> 
     </xsl:call-template> 
    </fo:block> 
    <xsl:if test="position() = last()"> 
     <xsl:apply-templates select="../legend" /> 
    </xsl:if> 
    <xsl:if test="@infoEntityIdent"> 
     <fo:block text-align="right" keep-with-previous="always"> 
      <xsl:value-of select="@infoEntityIdent" /> 
     </fo:block> 
    </xsl:if> 
    <fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always"> 
     <xsl:text>Fig </xsl:text> 
     <xsl:number count="figure" level="any" format="1" from="content" /> 
     <xsl:apply-templates select="../title" /> 
     <xsl:variable name="numSheets" select="count(../graphic)" /> 
     <xsl:choose> 
      <xsl:when test="$numSheets > 1"> 
       <xsl:text> (Sheet </xsl:text> 
       <xsl:number count="graphic" level="any" format="1" from="figure" /> 
       <xsl:text> of </xsl:text> 
       <xsl:value-of select="$numSheets" /> 
       <xsl:text>)</xsl:text> 
      </xsl:when> 
     </xsl:choose> 
    </fo:block> 
</xsl:template> 

私もfigure/graphicテンプレートの最初のfo:blockにグラフィックのIDを動かしました。最後のfo:blockに置くと、グラフィックへのリンクをたどるたびにグラフィックが表示されるようにスクロールすることになります。

+0

おかげで、トニー。'Graphic'は' figure'の外に出ることはできません。 – Caroline

+0

あなたの時間を感謝します、トニー。私はこれをあなたの提案と共に使用するようにしましたが、多くの場合、図ごとに複数の図があり、期待通りに常に最初の図に行くことになります。 'table'のようなidsを持つ他の項目がありますので、' xsl:key name = "id" match = "table" use = "@ id" /> 'を' xsl:key'宣言に追加しました。あなたの解決策は私が持っていたものを上回るものです。私のフォーマッタはAntenna House 6.2です。 – Caroline

+0

ありがとう、トニー、私はあなたの改訂コードで動作するようにグラフィックリンクを取得しました。 AHのサポートは、実装するのがやや簡単だった ' 'に' 'を追加する必要があると指摘しました。私はあなたの努力に感謝しています。 – Caroline

0

これは、DO-グラフィックテンプレートで<fo:external-graphic><xsl:attribute name="id">を追加することを提案し、それが問題を解決するために思われました:

<xsl:template name="do-graphic"> 
    <xsl:param name="include-graphic" select="true()"/> 
    <xsl:variable name="content-width"> 
     <xsl:choose> 
      <xsl:when test="@reproductionWidth != ''"> 
       <xsl:value-of select="@reproductionWidth"/> 
       <xsl:call-template name="checkForUom"> 
        <xsl:with-param name="measure" select="@reproductionWidth"/> 
       </xsl:call-template> 
      </xsl:when> 
      <!-- coding for reproduction scale based on clarifications in Issue 4.1 --> 
      <xsl:when test="@reproductionScale != ''"> 
       <xsl:value-of select="@reproductionScale"/> 
       <xsl:text>%</xsl:text> 
      </xsl:when> 
      <xsl:otherwise>95%</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:variable name="content-height"> 
     <xsl:choose> 
      <xsl:when test="@reproductionHeight != ''"> 
       <xsl:value-of select="@reproductionHeight"/> 
       <xsl:call-template name="checkForUom"> 
        <xsl:with-param name="measure" select="@reproductionWidth"/> 
       </xsl:call-template> 
      </xsl:when> 
      <!-- coding for reproduction scale based on clarifications in Issue 4.1 --> 
      <xsl:when test="@reproductionScale != ''"> 
       <xsl:value-of select="@reproductionScale"/> 
       <xsl:text>%</xsl:text> 
      </xsl:when> 
      <xsl:otherwise>95%</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:choose> 
     <xsl:when test="$include-graphic"> 
      <fo:external-graphic src="{unparsed-entity-uri(@infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}"> 
      <xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="@id"/></xsl:attribute> 
      </fo:external-graphic> 
     </xsl:when> 
     <xsl:otherwise> 
      <fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red"> 
       <fo:block>Graphic Not Included</fo:block> 
      </fo:inline-container> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 
関連する問題