我创建了一个XSLT样式表,用于查找并删除一个节点。这个功能非常好用。现在我想检查是否存在某个特定的节点,如果存在就删除它。因此,我尝试添加一个if语句,但是遇到了以下错误:
"编译错误:文件dt.xls第10行元素模板,元素模板只允许作为样式表的子元素"
我认为我理解了错误的原因,但不确定如何解决它。
"编译错误:文件dt.xls第10行元素模板,元素模板只允许作为样式表的子元素"
我认为我理解了错误的原因,但不确定如何解决它。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="Ad">
<xsl:template match="node()|@*">
<xsl:if test="name-ad-size">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:template>
<xsl:template match="phy-ad-width"/>
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="codeListing sampleOutput"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<template...
。 - Jim Garrisonxsl:if
,所以我猜测问题的其余部分。因为它不在代码块中,所以其余部分消失了。无论如何,答案应该保持大致相同;-) - Abel