文档函数为空

Document function empty

我有一个这样的变量:

<xsl:variable name="link_Description">
<xsl:choose>
  <xsl:when test="/map/topicref/@navtitle = 'Description'">
    <xsl:value-of select="/map/topicref[@navtitle='Description']/@href"/>
  </xsl:when>
  <xsl:when test="/map/topicref/@navtitle = '产品描述'">
    <xsl:value-of select="/map/topicref[@navtitle='产品描述']/@href"/>
  </xsl:when>
  <xsl:when test="/map/topicref/@navtitle = '説明'">
    <xsl:value-of select="/map/topicref[@navtitle='説明']/@href"/>
  </xsl:when>
</xsl:choose>
</xsl:variable>

这个变量return我文档的文件名:TAMS0303141848SMD_zh-cn.dita

问题是当我像这样应用 document() 函数时:document($link_Description) 什么都没有 return。

在检查中文和日文之前,我使用了这个变量:

<xsl:variable name="link_Description" select="/map/topicref[@navtitle='Description']/@href"/>

使用这个变量,document() 函数 document($link_Description) return 得到了好的结果

DITA XML 代码输入:

 <map id="DocID026018" rev="2" title="STHV800" class="- map/map " xml:lang="zh-cn">
   <topicref navtitle="Features" class="- map/topicref " href="TAMS0303141517SMD_zh-cn.dita"/>
   <topicref navtitle="Description" class="- map/topicref " href="TAMS0303141848SMD_zh-cn.dita" />
   <topicref navtitle="sdfsdf" class="- map/topicref " href="TAMS0303141932SMD_zh-cn.dita"/>
</map>

我认为问题可能是当你使用

<xsl:variable name="v" select="/a/b/c"/>

变量的值是源文档中的一个节点,具有源文档的基本 URI,但是当您这样做时

<xsl:variable name="w">
  <xsl:value-of select="/a/b/c"/>
</xsl:variable>

那么这个变量的值就是一个新构造的节点,它的base URI就是stylesheet的base URI。如果源文档包含相对于源文档的相对 URI,则需要使用 document() 的第二个参数将基本 URI 设置为源文档 URI:

document($w, /)

或者,使变量不那么冗长:

<xsl:variable name="link_Description" 
select="/map/topicref[@navtitle = ('Description', '产品描述', '説明')][1]/@href"/>