XSLT删除同名节点中的节点

我有一个XML文档。

在其他para个节点中有para个节点的负载。

我要删除其中的内容,并保持内部文本与其他para节点内部文本的连接。

示例XML

<document>
<head>
<front>The front page</front>
</head>
<h1>
<para id="1234">This is the inner text <para> it needs joining together</para> maybe with other text</para>
</h1>
</document>

所需的输出

<document>
<head>
<front>The front page</front>
</head>
<h1>
<para id='1234'>This is the inner text it needs joining together maybe with other text</para>
</h1>
</document>
lisa7262 回答:XSLT删除同名节点中的节点

这很简单:

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

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

<xsl:template match="para/para">
    <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>
本文链接:https://www.f2er.com/3065618.html

大家都在问