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

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中复制整个节点时跳过元素_Xslt_Xpath_Xslt 1.0 - Fatal编程技术网

在xslt中复制整个节点时跳过元素

在xslt中复制整个节点时跳过元素,xslt,xpath,xslt-1.0,Xslt,Xpath,Xslt 1.0,是否可以从节点跳过元素?例如,我们将节点设为Test,它有子元素x,y,z。我想复制整个Test节点,但不想在最终结果中包含z元素。我们能否在select的副本中使用not()?我试过了,但没用 谢谢 不,无法控制正在复制的内容中发生的事情。这就是带有选择性省略的身份模板的用途: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method

是否可以从节点跳过元素?例如,我们将节点设为
Test
,它有子元素
x
y
z
。我想复制整个
Test
节点,但不想在最终结果中包含
z
元素。我们能否在select的副本中使用
not()
?我试过了,但没用

谢谢

不,
无法控制正在复制的内容中发生的事情。这就是带有选择性省略的身份模板的用途:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <!-- Identity template -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <xsl:apply-templates select="Test" />
  </xsl:template>

  <!-- Omit z from the results-->
  <xsl:template match="z" />
</xsl:stylesheet>

应用于此XML时:

<n>
  <Test>
    <x>Hello</x>
    <y>Heeelo</y>
    <z>Hullo</z>
  </Test>
</n>

你好
希埃洛
胡洛
结果是:

<Test>
  <x>Hello</x>
  <y>Heeelo</y>

</Test>

你好
希埃洛
不,
无法控制正在复制的内容内部发生的情况。这就是带有选择性省略的身份模板的用途:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <!-- Identity template -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <xsl:apply-templates select="Test" />
  </xsl:template>

  <!-- Omit z from the results-->
  <xsl:template match="z" />
</xsl:stylesheet>

应用于此XML时:

<n>
  <Test>
    <x>Hello</x>
    <y>Heeelo</y>
    <z>Hullo</z>
  </Test>
</n>

你好
希埃洛
胡洛
结果是:

<Test>
  <x>Hello</x>
  <y>Heeelo</y>

</Test>

你好
希埃洛
不,
无法控制正在复制的内容内部发生的情况。这就是带有选择性省略的身份模板的用途:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <!-- Identity template -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <xsl:apply-templates select="Test" />
  </xsl:template>

  <!-- Omit z from the results-->
  <xsl:template match="z" />
</xsl:stylesheet>

应用于此XML时:

<n>
  <Test>
    <x>Hello</x>
    <y>Heeelo</y>
    <z>Hullo</z>
  </Test>
</n>

你好
希埃洛
胡洛
结果是:

<Test>
  <x>Hello</x>
  <y>Heeelo</y>

</Test>

你好
希埃洛
不,
无法控制正在复制的内容内部发生的情况。这就是带有选择性省略的身份模板的用途:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <!-- Identity template -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <xsl:apply-templates select="Test" />
  </xsl:template>

  <!-- Omit z from the results-->
  <xsl:template match="z" />
</xsl:stylesheet>

应用于此XML时:

<n>
  <Test>
    <x>Hello</x>
    <y>Heeelo</y>
    <z>Hullo</z>
  </Test>
</n>

你好
希埃洛
胡洛
结果是:

<Test>
  <x>Hello</x>
  <y>Heeelo</y>

</Test>

你好
希埃洛