你能在 document() 函数中有 XSL 变量吗?

Hum*_*Sky 3 xml xslt

这工作得很好:

<xsl:variable 
     name="issue_info_file" 
     select="document('/issues/2010/12/08/info.xml')
                /page-components/issue-metadata-component/title"/>
Run Code Online (Sandbox Code Playgroud)

但这不会:

<xsl:variable 
     name="issue_info_file" 
     select="string(concat($full_issue_path,'/info.xml'))"/>
<xsl:variable 
     name="issue_title" 
     select="document($issue_info_file)
                /page-components/issue-metadata-component/title"/>
Run Code Online (Sandbox Code Playgroud)

有没有人在 XSLT 中甚至允许这样做?如果没有,是否有人推荐使用动态变量打开文件的解决方案?

小智 5

我不知道这个问题是否仍然存在,但似乎没有答案。我在我的 XSL 文件中使用了此代码。

<xsl:variable name="docRoot">../sitemap/</xsl:variable>
<xsl:variable name="fullDocRoot" select="string(concat($docRoot,'sitemap.xml'))"/>
<xsl:for-each select="document($fullDocRoot)/root/sitemap/loc">
Run Code Online (Sandbox Code Playgroud)

希望能帮助某人。