Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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 - Fatal编程技术网

xslt匹配和剥离

xslt匹配和剥离,xslt,Xslt,我有一个这样的XML结构,只是一些有效的XML结构与HTML标记混合。我正在尝试匹配节中的MyHeader,并将其设置为空 也就是说,在这个结构上运行XSLT之后,我不想打印MyHeader标记 <abstract> <section> <p>MyHeader</p> <p> other content in section </p> <h1> other content in section </h1&

我有一个这样的XML结构,只是一些有效的XML结构与HTML标记混合。我正在尝试匹配节中的
MyHeader

,并将其设置为空

也就是说,在这个结构上运行XSLT之后,我不想打印
MyHeader

标记

<abstract>
<section>
<p>MyHeader</p>

<p> other content in section </p>
<h1> other content in section </h1>

</section>
</abstract>

我的头

第节中的其他内容

第节中的其他内容
下面是我在XSL中尝试的内容

<xsl:template match="abstract/section/p">
        <xsl:choose>
            <xsl:when test="text() ='MyHeader'"></xsl:when>
            <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
        </xsl:choose>
</xsl:template>

我上面的代码有什么问题吗?我没有看到我的头标签被剥掉


乍一看,这应该是可行的,所以我认为问题可能在于XSLT的另一部分。例如,其他一些模板可能与p元素匹配。如果可能的话,您可以发布完整的XSLT文件吗?非常感谢。我同意发布的示例应该有效,但我强烈建议将模板缩短为
,这足以删除元素和您的
xsl:否则,
由内置模板完成。
<xsl:template match="abstract/section/p">
        <xsl:choose>
            <xsl:when test="text() ='MyHeader'"></xsl:when>
            <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
        </xsl:choose>
</xsl:template>

 what's wrong with my code
<xsl:template match="abstract/section/p[.='MyHeader']"/>