【发布时间】:2016-03-08 21:35:54
【问题描述】:
这个问题一部分是 XSL-FO,一部分是 XSLT,一部分是 DITA。一般来说,这个问题是试图解决我在fo:marker 上做错了什么,并了解我正在尝试的事情是否可行。
我正在尝试使用 fo:marker 存储来自特定元素的文本,然后像您预期的那样在标题中检索该文本。我这样做是作为 DITA 插件的一部分的自定义样式表的一部分。这个想法是该插件用于列出一系列程序步骤的文档。这些程序的步骤通常包括一堆图片。因此,要求是当一个步骤跨越页面时,该步骤的第一句充当各种运行的标题。在 DITA 中,步骤的第一句被捕获在 cmd 元素中。所以,我的想法是我可以使用fo:marker 设置处理cmd 元素的模板。
这是cmd 的模板与我添加的标记的样子:
<xsl:template match="*[contains(@class, ' task/cmd ')]" priority="1">
<fo:block xsl:use-attribute-sets="cmd">
<xsl:call-template name="commonattributes"/>
<xsl:if test="../@importance='optional'">
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Optional Step'"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:if>
<fo:inline>
<fo:marker marker-class-name="current-step"/>
</fo:inline>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
这不起作用。当我像这样修改模板时,我对此进行了一些尝试,并且只能让它在info 元素上工作,这是cmd 的兄弟元素:
<xsl:template match="*[contains(@class, ' task/info ')]">
<fo:block xsl:use-attribute-sets="info">
<fo:inline>
<fo:marker marker-class-name="current-step">
<xsl:apply-templates/>
</fo:marker>
</fo:inline>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
问题是,我用 cmd 元素尝试了这个构造(即包含一个 apply-templates 指令),但它仍然没有产生任何结果。
我所描述的是否可能?为什么我的标记仅在我包含应用模板指令且仅适用于 info 元素时才有效?
【问题讨论】: