Reputation: 19
Experts, i need to write XSLT 1.0 code to remove the ITEM under IT_EPC_LIST when EPC= (00), all other ITEMs must be passed as it is.
i attached sample input and output as below. Please check.
Input:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:AIF xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
<IT_ATTRIBUTES>
<item>
<NAME>check</NAME>
<VALUE>T</VALUE>
</item>
</IT_ATTRIBUTES>
<IT_EPC_LIST>
<item>
<PARENT_EPC/>
<EPC>(01)0541378700</EPC>
</item>
<item>
<PARENT_EPC/>
<EPC>(00)</EPC>
</item>
<item>
<PARENT_EPC/>
<EPC>(01)0541378(21)1000169</EPC>
</item>
<item>
<PARENT_EPC/>
<EPC>(01)0541378(21)1000180</EPC>
</item>
</IT_EPC_LIST>
<IV_BATCH/>
<IV_TEST_RUN/>
</ns1:AIF>
** Desired Output:**
<?xml version="1.0" encoding="UTF-8"?>
<ns1:AIF xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
<IT_ATTRIBUTES>
<item>
<NAME>check</NAME>
<VALUE>T</VALUE>
</item>
</IT_ATTRIBUTES>
<IT_EPC_LIST>
<item>
<PARENT_EPC/>
<EPC>(01)0541378700</EPC>
</item>
<item>
<PARENT_EPC/>
<EPC>(01)0541378(21)1000169</EPC>
</item>
<item>
<PARENT_EPC/>
<EPC>(01)0541378(21)1000180</EPC>
</item>
</IT_EPC_LIST>
<IV_BATCH/>
<IV_TEST_RUN/>
</ns1:AIF>
** XSLT I used is below:**
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="IT_EPC_LIST[ not(.// EPC)]"/>
</xsl:stylesheet>
This XSLT not removing the ITEMS as per the requirement, Can you please assist here..
Upvotes: 1
Views: 74
Reputation: 2714
I think the template you want is this :
<xsl:template match="IT_EPC_LIST/item[EPC='(00)']"/>
Upvotes: 2