在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>
你好
希埃洛