Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt Xpath:从每个循环的文档节点变量中选择节点_Xslt_Xpath - Fatal编程技术网

Xslt Xpath:从每个循环的文档节点变量中选择节点

Xslt Xpath:从每个循环的文档节点变量中选择节点,xslt,xpath,Xslt,Xpath,我遇到了一个预期的问题,我想知道是否有比我更好的解决方案 因此,我有一个文档节点变量: <xsl:variable name="variableNode" as="document-node()"> <xsl:document> <root> <element>...content...</element> <root>

我遇到了一个预期的问题,我想知道是否有比我更好的解决方案

因此,我有一个文档节点变量:

   <xsl:variable name="variableNode" as="document-node()">
        <xsl:document>
            <root>
             <element>...content...</element>
        <root>  
        </xsl:document>    
    </xsl:variable>

…内容。。。
此文档节点变量的内容稍后由for each循环处理:

<xsl:for-each select="$variableNode/root/element">
...content...
</xsl:for-each>

…内容。。。
在这个for each循环的内容中,我试图通过这个xslt样式表获取实际xml文件being进程的元素。但那没用

因此,我将文件名放入如下变量中

<xsl:variable name="actual_filename" select="base-uri()"/>

并通过doc函数得到所需的元素。(doc($actual_filename)/)

这在我的例子中效果很好,但我想知道这是否是一个优雅的解决方案,特别是如果输入不是文件而是其他xml内容


你能想出更好的解决办法吗?谢谢大家!

通常的方法是顶级的

<xsl:variable name="main-root" select="/"/>

若要将主输入文档节点存储在变量中,则在for each或模板中,使用来自不同文档的上下文节点,您始终可以访问该变量

<xsl:for-each select="$variableNode/root/element">
  <xsl:value-of select="$main-root//foo[@id = current()/@id]"/>
</xsl:for-each>

通常的方法是顶级

<xsl:variable name="main-root" select="/"/>

若要将主输入文档节点存储在变量中,则在for each或模板中,使用来自不同文档的上下文节点,您始终可以访问该变量

<xsl:for-each select="$variableNode/root/element">
  <xsl:value-of select="$main-root//foo[@id = current()/@id]"/>
</xsl:for-each>

通常的方法是顶级

<xsl:variable name="main-root" select="/"/>

若要将主输入文档节点存储在变量中,则在for each或模板中,使用来自不同文档的上下文节点,您始终可以访问该变量

<xsl:for-each select="$variableNode/root/element">
  <xsl:value-of select="$main-root//foo[@id = current()/@id]"/>
</xsl:for-each>

通常的方法是顶级

<xsl:variable name="main-root" select="/"/>

若要将主输入文档节点存储在变量中,则在for each或模板中,使用来自不同文档的上下文节点,您始终可以访问该变量

<xsl:for-each select="$variableNode/root/element">
  <xsl:value-of select="$main-root//foo[@id = current()/@id]"/>
</xsl:for-each>