我需要使用 EPUB DITA OT 插件更改 EPUB 输出中的主题文件名:
我的 Ditamap 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pubmap
PUBLIC "urn:pubid:com.sam.doctypes:dita:pubmap" "pubmap.dtd">
<pubmap xml:lang="en-US">
<pubtitle>
<mainpubtitle outputclass="book">Sample Word</mainpubtitle>
</pubtitle>
<topicref href="topics/topic_1.dita">
<topicmeta>
<navtitle>Ram-Files-Raj (RFR)</navtitle>
<metadata/>
</topicmeta>
</topicref>
<topicref href="topics/topic_2.dita">
<topicmeta>
<navtitle>Files-Sampletitle (FST)</navtitle>
<metadata/>
</topicmeta>
</topicref>
</pubmap>
我的 topic_1.dita 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
PUBLIC "urn:pubid:com.sam.doctypes:dita:topic" "topic.dtd">
<topic id="topic_1" xml:lang="en-US" outputclass="Ram-Files-RajRFR"><title>Ram-Files-Raj (RFR)</title></topic>
我的 topic_2.dita 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
PUBLIC "urn:pubid:com.sam.doctypes:dita:topic" "topic.dtd">
<topic id="topic_2" xml:lang="en-US" outputclass="Files-SampletitleFST"><title>Files-Sampletitle (FST)</title></topic>
使用 DITA OT EPUB 插件中的以下模板更改文件名
<xsl:template match="*[df:class(., 'topic/topic')]" mode="generate-content">
<xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="false()"/>
<!-- This template generates the output file for a referenced topic.
-->
<!-- The topicref that referenced the topic -->
<xsl:param name="topicref" as="element()?" tunnel="yes"/>
<!-- Result URI to which the document should be written. -->
<xsl:param name="resultUri" as="xs:string" tunnel="yes"/>
<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] generate-content: handling topic <xsl:value-of select="name(.)"/>...</xsl:message>
<xsl:message> + [DEBUG] generate-content: Generating base HTML using default-mode HTML generation....</xsl:message>
</xsl:if>
<xsl:variable name="htmlNoNamespace" as="node()*">
<xsl:apply-templates select="." mode="map-driven-content-processing">
<xsl:with-param name="topicref" select="$topicref" as="element()?" tunnel="yes"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] generate-content: Generating XHTML from base HTML...</xsl:message>
</xsl:if>
<xsl:variable name="xhtml" as="node()*">
<xsl:apply-templates select="$htmlNoNamespace" mode="html2xhtml">
<xsl:with-param name="topicref" select="$topicref" as="element()?" tunnel="yes"/>
<xsl:with-param name="resultUri" as="xs:string" tunnel="yes" select="$resultUri"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] xhtml:
<xsl:sequence select="$xhtml"/></xsl:message>
</xsl:if>
<xsl:message> + [INFO] Writing topic <xsl:value-of select="$topicref/@href"/> to HTML file "<xsl:sequence select="$resultUri"/>"...</xsl:message>
<xsl:result-document format="html5"
href="{$resultUri}"
exclude-result-prefixes="opf">
<xsl:sequence select="$xhtml"/>
</xsl:result-document>
</xsl:template>
<xsl:template match="*[df:isTopicRef(.)]" mode="generate-content">
<xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="false()"/>
<xsl:param name="rootMapDocUrl" as="xs:string" tunnel="yes"/>
<!-- <xsl:variable name="doDebug" as="xs:boolean" select="true()"/>-->
<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] Handling topicref to "<xsl:sequence select="string(@href)"/>" in mode generate-content</xsl:message>
</xsl:if>
<xsl:variable name="topic" select="df:resolveTopicRef(.)" as="element()*"/>
<xsl:choose>
<xsl:when test="not($topic)">
<xsl:message> + [WARNING] generate-content: Failed to resolve topic reference to href "<xsl:sequence select="string(@href)"/>"</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="topicResultUri"
select="htmlutil:getTopicResultUrl($outdir, root($topic), $rootMapDocUrl, $doDebug)"
as="xs:string"
/>
<!-- Do href fixup before doing full default-mode processing: -->
<xsl:variable name="tempTopic" as="document-node()">
<xsl:document>
<xsl:apply-templates select="$topic" mode="href-fixup">
<xsl:with-param name="topicResultUri" select="$topicResultUri"
tunnel="yes"/>
<xsl:with-param name="topicref" as="element()" select="." tunnel="yes"/>
</xsl:apply-templates>
</xsl:document>
</xsl:variable>
<!-- Apply templates in default mode to the topic with fixed up hrefs: -->
<xsl:apply-templates select="$tempTopic" mode="#current">
<xsl:with-param name="topicref" as="element()" select="." tunnel="yes"/>
<xsl:with-param name="resultUri" select="$topicResultUri"
tunnel="yes"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
epub 输出中的输出主题文件名我得到“topic_1_d76.xhtml”、“topic_2_d77.xhtml”等...但我需要主题标题作为 epub 输出中的文件名“Ram_Files_Raj_RFR.xhtml”、“Files_Sampletitle_FST .xhtml”。
请就这个问题向我提出建议。
提前致谢