XSLを使用して不要なスペースエレメントを削除します。私がテストだ不要なスペースエレメントを削除する必要があります
XML:私が使用
<Body>
<h1>abc</h1>
<h1>efg</h1>
<p>efgh</p>
<h1> </h1>
</Body>
は、XSL:
<xsl:template match="Body">
<xsl:copy>
<xsl:for-each-group select="*" group-adjacent="boolean(self::h1)">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<h1>
<xsl:apply-templates select="current-group()/node()"/>
</h1>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
私が手出力:
<Body>
<h1>abcefg</h1>
<p>efgh</p>
<h1> </h1>
</Body>
私は希望の出力:
<Body>
<h1>abcefg</h1>
<p>efgh</p>
</Body>
スペース値を持つ要素を削除する必要があります。お知らせ下さい。事前にありがとう
入力がどのように見えるか、どのような結果が得られるかを詳しく説明する必要があると思います。最後の 'h1'要素は空ではなく、空白で埋められますが、何らかのデータが入っていますか? 'h1'要素の新しいグループにしますか? –