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,我是XSLT新手,所以我尝试应用一个特定的模板(头组件),然后加载除头模板之外的所有模板 <html> <head> <title>My page</title> </head> <body> <div class="header"> <xsl:apply-templates select="page-components/header-component"

我是XSLT新手,所以我尝试应用一个特定的模板(头组件),然后加载除头模板之外的所有模板

    <html>
  <head>
    <title>My page</title>
  </head>
  <body>
    <div class="header">
       <xsl:apply-templates select="page-components/header-component"/>
    </div>
    <div>
      <xsl:apply-templates select="page-components/*"/>  
    </div>
  </body>
</html>

我的页面
在我的解决方案中,头组件被加载了两次(同样明显)。

而不是写入

<xsl:apply-templates select="page-components/*"/>

只要写

<xsl:apply-templates select="page-components/*[not(name()='header-component')]"/>


排除已处理的元素。

您的解决方案有效。你能给我推荐一些在线信息,让我可以正确地学习XSLT吗?我想我是通过反复试验才学会的。尝试构建一些东西,遇到一些问题,用谷歌搜索或者在这里询问。我记得我读了很多w3schools.com。@TiagoNeto-如果你滚动到的底部,下面列出了一些在线资源。我没有使用过任何一款,但它们是迪米特里·诺瓦切夫(Dimitre Novatchev)做的,所以我很乐意推荐它们。