XSL-FO:fo:marker可以用来存储什么吗?
XSL-FO: Can fo:marker be used to store anything?
这个问题是 XSL-FO、XSLT 和 DITA 的一部分。总的来说,这个问题是试图解决我在 fo:marker
上做错了什么,并了解我正在尝试的事情是否可行。
我正在尝试使用 fo:marker 存储来自特定元素的文本,然后像您预期的那样在 header 中检索该文本。我这样做是作为自定义样式 sheet 的一部分,它是 DITA 插件的一部分。这个想法是插件是用于列出一系列程序步骤的文档。这些程序的步骤通常包括一堆图片。因此,要求是当一个步骤跨页时,该步骤的第一句话充当 运行 header 之类的。在 DITA 中,步骤的第一句话被捕获在 cmd
元素中。所以,我的想法是我可以设置处理 cmd
元素和 fo:marker
的模板。
下面是 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 指令),但它仍然没有产生任何结果。
我所描述的是可能的吗?为什么我的标记仅在包含 apply-templates 指令且仅适用于 info
元素时才有效?
您需要 fo:marker
中的内容,因为它是 "may be retrieved and formatted from within an fo:static-content ... using an fo:retrieve-marker" 中 fo:marker
的内容。参见 http://www.w3.org/TR/xsl11/#fo_marker
我不知道为什么具有内容和相同标记 class 名称的 fo:marker
在这两种情况下都不起作用。您在 fo:retrieve-marker
上使用 retrieve-position="first-including-carryover"
吗?您是否在 info
的 fo:marker
中留下了 cmd
的 fo:marker
?
一个完全独立的替代方案可能是将每个步骤放在 single-column table 中,没有边框,并将 cmd
的内容放在 table header.
这个问题是 XSL-FO、XSLT 和 DITA 的一部分。总的来说,这个问题是试图解决我在 fo:marker
上做错了什么,并了解我正在尝试的事情是否可行。
我正在尝试使用 fo:marker 存储来自特定元素的文本,然后像您预期的那样在 header 中检索该文本。我这样做是作为自定义样式 sheet 的一部分,它是 DITA 插件的一部分。这个想法是插件是用于列出一系列程序步骤的文档。这些程序的步骤通常包括一堆图片。因此,要求是当一个步骤跨页时,该步骤的第一句话充当 运行 header 之类的。在 DITA 中,步骤的第一句话被捕获在 cmd
元素中。所以,我的想法是我可以设置处理 cmd
元素和 fo:marker
的模板。
下面是 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 指令),但它仍然没有产生任何结果。
我所描述的是可能的吗?为什么我的标记仅在包含 apply-templates 指令且仅适用于 info
元素时才有效?
您需要 fo:marker
中的内容,因为它是 "may be retrieved and formatted from within an fo:static-content ... using an fo:retrieve-marker" 中 fo:marker
的内容。参见 http://www.w3.org/TR/xsl11/#fo_marker
我不知道为什么具有内容和相同标记 class 名称的 fo:marker
在这两种情况下都不起作用。您在 fo:retrieve-marker
上使用 retrieve-position="first-including-carryover"
吗?您是否在 info
的 fo:marker
中留下了 cmd
的 fo:marker
?
一个完全独立的替代方案可能是将每个步骤放在 single-column table 中,没有边框,并将 cmd
的内容放在 table header.