Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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应用模板选择属性中使用字符串_Xslt - Fatal编程技术网

在xslt应用模板选择属性中使用字符串

在xslt应用模板选择属性中使用字符串,xslt,Xslt,我有一个包含xpath查询的字符串,它将作为一个参数传递,或者包含在我现在不知道的外部源中,但这是动态的 我想在“应用模板”命令的“选择属性”中使用此字符串 <!--this is external xml file to be queried.--> <xsl:variable name="v" select="document('foo.xml')"></xsl:variable> <xsl:template match="/Selec

我有一个包含xpath查询的字符串,它将作为一个参数传递,或者包含在我现在不知道的外部源中,但这是动态的

我想在“应用模板”命令的“选择属性”中使用此字符串

  <!--this is external xml file to be queried.-->
  <xsl:variable name="v" select="document('foo.xml')"></xsl:variable>

  <xsl:template match="/Selector">
    <!--this is our variable = query-->
    <xsl:variable name="xpathquery" select="string(@select)" />

    <!--i want to say this!-->
    <xsl:apply-templates select="$v/$xpathquery" mode="ui" />
  </xsl:template>

  <xsl:template mode="ui" match="*">
    <foo></foo>
  </xsl:template>


我希望我能解释一下。谢谢。

您使用的XSLT版本是什么?Saxon 9,所以我想它支持1.0、2.0和3.0。您可能需要XSLT3。我自己对此没有太多经验,但这可能很有用:您需要某种
evaluation()
函数,它只支持一些XSLT 1或2处理器的扩展,并且在XSLT3.0中是标准的。您还可以考虑两步转换,其中第一样式表以正确的路径输出第二步,然后可以在单独的步骤中应用。