xslt - 需要数字格式作为 dita ot epub 输出的 xhtml 文件的前缀
问题描述
我已使用 Dita OT 1.8.5 进行 epub 转换:但我需要数字序列格式 01、02、03 .. epub 输出中 xhtml 文件名的前缀。
我已将 html-generation-utils.xsl 函数中的代码更改为文件名的编号顺序,如下所示:
<xsl:function name="htmlutil:constructHtmlResultTopicFilename" as="xs:string">
<xsl:param name="topic" as="document-node()"/>
<xsl:variable name="topicFilename"
select="concat(htmlutil:getResultTopicBaseName($topic), $OUTEXT)"
as="xs:string"/>
<xsl:for-each select="$topic">
<xsl:variable name="number"><xsl:value-of select="format-number(position(),'00')"/></xsl:variable>
<xsl:sequence select="concat($number, $topicFilename)"/>
</xsl:for-each>
</xsl:function>
我仅将所有前缀的文件名输出为“01”。
但我需要前缀为 01, 02, 03, ...
请建议。
提前致谢
解决方案
<xsl:template name="get-result-topic-base-name-single-dir">
<xsl:param name="topicUri" as="xs:string"/>
<xsl:variable name="topicID" select="/*[contains(@class, ' topic/topic ')]/@id" />
<xsl:variable name="topic_count">
<xsl:for-each select="$collected-data-global">
<xsl:for-each select="mapdriven:collected-data/enum:enumerables/enum:topicref[@topicID=$topicID]">
<xsl:number count="enum:topicref" format="01" />
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="maintitle"><xsl:apply-templates select="/*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="text-only"/></xsl:variable>
<xsl:variable name="filename_characters_to_remove">~!@#$%^*()_+`-={}|[]\:";'?,./ <>&‘’“”–—</xsl:variable>
<xsl:variable name="puncremoved" select="translate($maintitle, $filename_characters_to_remove,'')"/>
<xsl:variable name="baseName" select="translate($puncremoved, ' ','_')" as="xs:string"/>
<xsl:sequence select="concat($topic_count, '_', $baseName)"/>
</xsl:template>
推荐阅读
- postgresql - 使用 postgres 在 GORM 中使用 struct 进行 Like/gte/lte 查询
- node.js - 如何每天在特定时间停止节点 cron?
- python - macOS Catalina 上的 Mujoco:导入和构建 mujoco_py 时出现“ld:未知选项:-platform_version”
- excel - 从 Excel 中包含逗号分隔值的两个单元格中提取公共值
- android - 如何降低firebase实时数据库下载成本?
- android - 我在android中的自定义通知有问题
- c++ - 我的表情符号程序在 C++ 中显示带有问号的框
- javascript - jquery正则表达式验证完成后如何提交?
- javascript - Ajax 调用更改图标
- javascript - 无法将第二个 URL 推送到我的 Discord 机器人的队列中