title: Remove XML element with empty child in WSO2 ESB 4.0.3
body: <p>I have a pass-through proxy web service set up in ESB that grabs data from a DSS endpoint, resembling the following:</p>
  
  <pre><code>&lt;Products xmlns="http://wso2.host.com/Products"&gt;
      &lt;Product&gt;
          &lt;SKU&gt;12345678&lt;/SKU&gt;
          &lt;ItemName xmlns="null"&gt;T Shirt&lt;/ItemName&gt;
          &lt;Restrictions&gt;
              &lt;Restriction&gt;
                  &lt;Reason&gt;Reason A&lt;/Reason&gt;
                  &lt;Code&gt;12&lt;/Code&gt;
              &lt;/Restriction&gt;
          &lt;/Restrictions&gt;
      &lt;/Product&gt;
  &lt;/Products&gt;
  </code></pre>
  
  <p>There is the possibility that a product may not have a restriction, and will come through as such:</p>
  
  <pre><code>&lt;Products xmlns="http://wso2.host.com/Products"&gt;
      &lt;Product&gt;
          &lt;SKU&gt;12345678&lt;/SKU&gt;
          &lt;ItemName xmlns="null"&gt;T Shirt&lt;/ItemName&gt;
          &lt;Restrictions&gt;
              &lt;Restriction&gt;
                  &lt;Reason/&gt;
                  &lt;Code/&gt;
              &lt;/Restriction&gt;
          &lt;/Restrictions&gt;
      &lt;/Product&gt;
  &lt;/Products&gt;
  </code></pre>
  
  <p>I'd like to remove the whole <code>&lt;Restrictions&gt;</code> element so the response shows as such:</p>
  
  <pre><code>&lt;Products xmlns="http://wso2.host.com/Products"&gt;
      &lt;Product&gt;
          &lt;SKU&gt;12345678&lt;/SKU&gt;
          &lt;ItemName xmlns="null"&gt;T Shirt&lt;/ItemName&gt;
      &lt;/Product&gt;
  &lt;/Products&gt;
  </code></pre>
  
  <p>I'm trying to use an Enrich mediator in the out sequence to replace it with nothing, but I'm not sure what to use to replace it with, or if that's really the best way to do it. The Xpath expression I have is as follows:</p>
  
  <pre><code>/Products/Product/Restrictions[string-length(Restriction/Reason[text()])=0]
  </code></pre>
  
  <p>Any help is super appreciated, I'm not super familiar with WSO2 and might be completely missing the right answer. Thanks in advance.</p>
  
  <hr>
  
  <p>UPDATE: I've followed recommendations by @Jorge Infante Osorio and added an XSLT mediator, which references a Local Entry defined as the following:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" /&gt;
  
  &lt;xsl:template match="@* | node()"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@* | node()"/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="Restrictions"/&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>This still isn;t working. However, I am able to get them removed by adding 3 XSLT mediators and pointing them at this local entry:</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
      &lt;xsl:output omit-xml-declaration="yes" indent="yes" /&gt;
      &lt;xsl:strip-space elements="*" /&gt;
      &lt;xsl:template match="node()|@*"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="node()|@*" /&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="*[not(node())]   |    *[not(node()[2])    and      node()/self::text()    and      not(normalize-space())      ]   " /&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I tried modifying this to match the Restrictions template like @Jorge Infante Osorio had in his example, but I can't seem to get it correct.</p>