Ed: following from Copy parallel element as child element of another element:
Input XML
<root>
<order orderId="12345">
<cartId>12346</cartId>
<orderPayment paymentId="1234">
<debitCardPayment>
<chargeAmount currencyCode="USD">22.20</chargeAmount>
<debitCard>
<PIN>1234</PIN>
<PIN1></PIN1>
</debitCard>
</debitCardPayment>
</orderPayment>
</order>
<context>
</context>
</root>
Need OUTPUT
<order>
.....
</order>
<orderPayment>
.....
<debitCard>
<PIN>1234</PIN>
</debitCard>
</orderPayment>
<context>
</context>
I have XSLT as follows
<xsl:template match="Root">
<updateOrderCheckoutRequest version="1">
<xsl:apply-templates select="@*|node()"/>
<xsl:copy-of select="//orderPayment"/>
</updateOrderCheckoutRequest>
</xsl:template>
<xsl:template match="orderPayment"/>
<xsl:template match="order">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test=".='' and count(@*)=0">
<xsl:apply-templates select="@*|node()"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Which is copying empty elements also. Is there any possibility to remove empty elements while applying copy-of. Thanks in advance...