文档功能为空

时间:2015-08-12 09:08:16

标签: xml xslt filenames xslt-2.0 dita

我有一个这样的变量:

<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>

此变量返回我的文档的文件名:TAMS0303141848SMD_zh-cn.dita

问题是当我应用这样的文档()函数时:document($link_Description)什么都没有返回。

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

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

使用这个变量,document()函数document($link_Description)返回了良好的结果

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>

1 个答案:

答案 0 :(得分:1)

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

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

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

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

然后变量的值是一个新构造的节点,其基URI是样式表的URI。如果源文档包含相对于源文档的相对URI,则需要使用document()的第二个参数将基URI设置为源文档URI:

document($w, /)

或者,使变量更简洁:

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