Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
Xml XSLT'的细枝等价物是什么;s document()函数?_Xml_Xslt_Twig - Fatal编程技术网

Xml XSLT'的细枝等价物是什么;s document()函数?

Xml XSLT'的细枝等价物是什么;s document()函数?,xml,xslt,twig,Xml,Xslt,Twig,我正在将.XSL模板重写为.TWIG模板,但遇到了一个问题。 我不知道如何处理由.XML文件表示的特定数据源中的节点选择。 下面是我试图重写到TWIG中的.XSL代码片段↓ <!-- firstly I am selecting my .XML file that contains data --> <xsl:variable name="subscriptionData" select="document('../xml/subscriptions.xml')" />

我正在将.XSL模板重写为.TWIG模板,但遇到了一个问题。 我不知道如何处理由.XML文件表示的特定数据源中的节点选择。 下面是我试图重写到TWIG中的.XSL代码片段↓

<!-- firstly I am selecting my .XML file that contains data -->
<xsl:variable name="subscriptionData" select="document('../xml/subscriptions.xml')" />

<!-- then I am selecting a node in that .XML file -->
<xsl:variable name="data" select="$subscriptionData/root/subscription[position() = 1]" />

<!-- finally I can print out a specific property -->
<xsl:value-of select="$data/title" />

您不会在细枝模板中导入数据,而是将数据传递给它。也就是说,您可以调用
Twig\u TemplateWrapper::render(data)
。Cf.

您不需要在细枝模板中导入数据,而是将数据传递给它。也就是说,您可以调用
Twig\u TemplateWrapper::render(data)
。比照@Dormilich,这看起来很复杂。还有其他方法吗?你觉得简单的方法调用很复杂吗?(这看起来很复杂,因为我不知道你的后端)。最后,您无法将XSLT 1:1转换为Twig,因为两个系统在如何操作方面有不同的方法。
{# I don't know how to select that .XML file that contains data #}
{% set subscriptionData = ??????? %}

{# selecting a node inside .XML #}
{% set data = subscriptionData.root.subscription[0] %}

{# printing out a specific property #}
{{ data.title }}