Ich möchte kommentieren, welche para, die 'para 1' enthält, wie die Eingabe zusammen mit den untergeordneten Elementen.xsl: Kommentar nicht alle untergeordneten Elemente anwenden?
INPUT:
<root>
<section>
<title>aaaa</title>
<para>para 1 <i>italic</i></para>
</section>
<section>
<title>aaaa</title>
<para>para 2</para>
</section>
</root>
XSLT:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="para[contains(. , 'para 1')]">
<xsl:comment>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:comment>
</xsl:template>
OUTPUT:
<section>
<title>aaaa</title>
<!--para 1 italic-->
</section>
gewünschte Ausgangs alle Elemente kopiert werden sollen, wie es als Eingabe innerhalb Kommentar ist:
<section>
<title>aaaa</title>
<!--<para>para 1 <i>italic</i></para>-->
</section>
Dank @Rupesh. Ich habe diesen Weg gemacht, aber ich begegne einem neuen Szenario "Kommentar" bereits innerhalb von para in Eingabe. [d.h. para 1 kursiv ]. Dann produziert es kein XML in wohlgeformter Form. –
@Amrendra, aktualisierte Antwort. – Rupesh