【发布时间】:2015-09-28 13:06:03
【问题描述】:
为此苦苦挣扎了一会儿,现在要寻求帮助。在使用 XSL-FO 时在 PDF 输出中引用它时,我正在尝试获取正确的步骤编号。有了以前在这里得到的帮助,我有其他参考资料可以按需要工作。这些特殊的标签给我带来了麻烦。
这是用于 S1000D 航空出版规范中的故障隔离树:
<isolationStep id="step4"><isolationStepQuestion>Check for burnt-out lamps. Are lamps good?</isolationStepQuestion><isolationStepAnswer><yesNoAnswer><yesAnswer nextActionRefId="step6"/><noAnswer nextActionRefId="step8"/></yesNoAnswer></isolationStepAnswer></isolationStep>
如您所见,该问题有一个答案部分。这些答案对其他步骤有参考。在 PDF 中,我得到了正确编号的步骤,但是在呈现答案时,我得到了这个:
用于问题、答案和尝试编号以回答引用步骤的 XSL-FO:
<xsl:template match="isolationStep | isolationProcedureEnd">
<xsl:for-each select="note">
<fo:block font-weight="bold">Note</fo:block>
<xsl:apply-templates/>
</xsl:for-each>
<xsl:for-each select="caution">
<fo:block font-weight="bold" text-align="center">CAUTION</fo:block>
<xsl:apply-templates/>
</xsl:for-each>
<xsl:for-each select="warning">
<fo:block font-weight="bold" text-align="center">WARNING</fo:block>
<xsl:apply-templates/>
</xsl:for-each>
<fo:block id="{@id}" padding="5pt" font-size="10pt">
<!-- border-style="solid"
border-width=".1mm"-->
<!--<xsl:apply-templates/>-->
<fo:list-block space-after="2mm">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:number level="multiple" count="isolationMainProcedure/isolationStep | isolationProcedureEnd" format="1."/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<!--<xsl:apply-templates select="title"/>-->
<xsl:choose>
<xsl:when test="count(action) > 1">
<xsl:for-each select="action">
<fo:list-block space-after="2mm">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:number format="a."/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<!--<xsl:apply-templates/>-->
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="action">
<fo:block>
<xsl:apply-templates/>
</fo:block>
<!--<xsl:apply-templates/>-->
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="isolationStepQuestion"/>
<xsl:apply-templates select="isolationStepAnswer"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
</xsl:template>
<xsl:template match="isolationStep | isolationProcedureEnd" mode="nbr">
<xsl:variable name="origNbr">
<xsl:number level="multiple" format="1"/>
</xsl:variable>
<xsl:value-of select="$origNbr"/>
</xsl:template>
<xsl:template match="isolationStepQuestion">
<fo:block font-weight="bold">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="yesNoAnswer">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="yesAnswer">
<xsl:variable name="ref" select="@nextActionRefId"/>
<fo:block space-before="4pt" space-after="4pt" keep-with-previous="always">
<fo:inline><xsl:text>Yes: Go to </xsl:text>
<fo:basic-link internal-destination="{@nextActionRefId}" color="blue">Step <!--<xsl:value-of select="$yesref2"/>-->
<!--ancestor::isolationMainProcedure-->
<!--<xsl:apply-templates select="an../../../.././isolationStep | isolationProcedureEnd[@id=$yesref]" mode="nbr"/> ancestor::isolationMainProcedure[1]/-->
<xsl:apply-templates select="//isolationStep | isolationProcedureEnd[@id=$ref]" mode="nbr"/>
</fo:basic-link></fo:inline>
</fo:block>
</xsl:template>
<xsl:template match="noAnswer">
<xsl:variable name="ref" select="@nextActionRefId"/>
<fo:block keep-with-previous="always">
<fo:inline>
<xsl:text>No: Go to </xsl:text>
<fo:basic-link internal-destination="{@nextActionRefId}" color="blue">Step
<xsl:apply-templates select="//isolationStep | isolationProcedureEnd[@id=$ref]" mode="nbr"/>
</fo:basic-link></fo:inline>
</fo:block>
</xsl:template>
<xsl:template match="isolationStepAnswer">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="isolationStep | isolationProcedureEnd" mode="nbr">
<xsl:variable name="origNbr">
<xsl:number level="multiple" format="1"/>
</xsl:variable>
<xsl:value-of select="$origNbr"/>
</xsl:template>
此外,这些链接可以正常工作,并将您带到正确的位置。我只是在正确编号时遇到问题。
这是一个 XSL 2.0 样式表。任何帮助表示赞赏,在此先感谢。
【问题讨论】: