Experts, i need to write XSLT 1.0 code to eliminate the Record in the XML which is having empty fields.
Input:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns0:Accounts xmlns:ns0="urn:text.com:accounts">
<Recordset>
<Record>
<FIELD1>123</FIELD1>
<FIELD2/>
<FIELD3/>
<FIELD4>2020</FIELD4>
<FIELD5/>
</Record>
<Record>
<FIELD1/>
<FIELD2/>
<FIELD3/>
<FIELD4/>
<FIELD5/>
</Record>
<Record>
<FIELD1>89</FIELD1>
<FIELD2>098</FIELD2>
<FIELD3/>
<FIELD4>678</FIELD4>
<FIELD5>NEW</FIELD5>
<FIELD6/>
</Record>
<Record>
<FIELD1/>
<FIELD2/>
<FIELD3/>
<FIELD4/>
<FIELD5/>
</Record>
<Record>
<FIELD1/>
<FIELD2/>
<FIELD3/>
<FIELD4/>
<FIELD5/>
</Record>
</Recordset>
</ns0:Accounts>
** Desired Output:**
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns0:Accounts xmlns:ns0="urn:text.com:accounts">
<Recordset>
<Record>
<FIELD1>123</FIELD1>
<FIELD2/>
<FIELD3/>
<FIELD4>2020</FIELD4>
<FIELD5/>
</Record>
<Record>
<FIELD1>89</FIELD1>
<FIELD2>098</FIELD2>
<FIELD3/>
<FIELD4>678</FIELD4>
<FIELD5>NEW</FIELD5>
<FIELD6/>
</Record>
</Recordset>
</ns0:Accounts>
** XSLT I tried:**
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates
select="node()[boolean(normalize-space())]
|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This XSLT removing the empty fields in all the records, but my requirement is to remove the Record which is having all the empty fields. If the record contains one field with some value then we need to keep that record as it is. Please support..