Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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创建新表而不使用模板中的表_Xml_Xslt - Fatal编程技术网

Xml 为什么xslt创建新表而不使用模板中的表

Xml 为什么xslt创建新表而不使用模板中的表,xml,xslt,Xml,Xslt,我有一个这样的xml文件 <Root> ... <x></x> <node> ... <x></x> <y></y> </node> </Root> ... ... 我的xslt是 <xsl:template match="/"> <!-- proceed the treatment of the statement before

我有一个这样的xml文件

<Root>
 ...
 <x></x>
 <node>
  ...
  <x></x>
  <y></y>
 </node>
</Root>

...
...
我的xslt是

<xsl:template match="/">
 <!-- proceed the treatment of the statement before x-->
 <tr>
  <xsl:apply-templates match="Root/x"/>
 </tr>
 <tr>
  <xsl:apply-templates match="Root"/>
 </tr>
</xsl:template>

<xsl:template match="x">
  ...
</xsl:template match="x">

<xsl:template match="Root">
 <!--Proceed the treatment of the statement before x-->
 <tr>
  <xsl:apply-templates match="x"/>
 </tr>
 <!--Deal with y-->

...

匹配“/”的模板将创建一个表,并用xml文件中的所有节点填充该表。x可以出现在像“node”这样的每个元素中,并且每次都可能不同。“节点”也可以使用不同的内容多次出现

但当我使用这个xslt时,在处理了x之后,它为x之后的元素创建了一个新表,所以节点将位于一个新表中,也为y

有人知道怎么做吗?谢谢你,迪沃


match=“x”模板处理“x”的子元素。很抱歉让您误解,我只是忽略了创建表的代码。该表是在match=“/”模板中创建的。谢谢

看起来您正在处理“/”模板中的内容,然后在“根”模板中再次处理所有内容,因为“/”模板也明确应用了根模板


尝试删除“/”模板的定义,然后只做“Root”模板中的所有工作。

我不确定我是否理解您的问题。你能举个例子说明你想要得到什么样的XML输出吗?match=“x”模板在做什么?我在您的代码中没有看到任何内容,所以我想知道您在哪里创建表??语法不正确。必须是:。请说对。另外,请给出一个更有意义的例子。目前对这个问题的表述非常不清楚,要求投反对票。好的,迪米特。看来这已经是问题所在了。