Question for Copy input:
<Rel>
<IRel UID1="3a4d1d2909d0" UID2="35fe61082294" DefUID="AssetSupplier" />
<IObject UID="3a4d1d2909d0.AssetSupplier.35fe61082294" />
<SPXSupplier>
<ISPFOrganization />
<ISPFAdminItem />
<IObject UID="b73ebb87-cd36-4c25-b9ed-35fe61082294"
Description="local supplier made in form (10C)"
Name="CASTROL1200" />
<ISupplierOrganization />
</SPXSupplier>
</Rel>
Output: I only want to skip SPXSupplier and its child node in my output
<Rel>
<IRel UID1="3a4d1d2909d0" UID2="35fe61082294" DefUID="AssetSupplier" />
<IObject UID="3a4d1d2909d0.AssetSupplier.35fe61082294" />
</Rel>
currently I am using this copy which copy all the things including the child,
<xsl:copy-of select="self::node()"/>
I only want <Rel>
, <IRel>
and <IObject>
tags. excluding other stuff.
Here's a refinement of Alex's answer.
<xsl:template match="SPXSupplier"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
The empty template for SPXSupplier means that when you hit one of these elements, the subtree below that element is not processed. I've also used a version of the identity template that copies attributes unconditionally, which is more efficient.
xsl:copy-of
copies the whole subree. To exclude an SPXSupplier
element you can use the following approach:
<xsl:template match="//Rel">
<xsl:copy>
<xsl:apply-templates select="@*|IRel|IObject"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With