dataweave mapping when otherwise
<p>`Input:-</p>

<pre><code>{"id":
{
 "items" : [
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "balance_inquiry",
"method": "valuelink",
"order_number": "123",
"amount": "1000",
"currency_code": "CAD",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
},
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "balance_inquiry",
"method": "valuelink",
"order_number": "123",
"amount": "2000",
"currency_code": "",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
},  
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "authorize",
"method": "token",
"order_number": "123",
"amount": "3000",
"currency_code": "",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
}
</code></pre>

<p>]
}
}`</p>

<p>Output:- without any Null B, because I need to do to another mapping on the basis of this output with no Null B</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;A&gt;
  &lt;B&gt;
    &lt;merchant_ref&gt;icici&lt;/merchant_ref&gt;
    &lt;transaction_tag&gt;sdfhisdb&lt;/transaction_tag&gt;
    &lt;transaction_type&gt;balance_inquiry&lt;/transaction_type&gt;
    &lt;method&gt;valuelink&lt;/method&gt;
    &lt;order_number&gt;123&lt;/order_number&gt;
    &lt;amount&gt;1000&lt;/amount&gt;
    &lt;currency_code&gt;CAD&lt;/currency_code&gt;
    &lt;token&gt;
      &lt;token_type&gt;&lt;/token_type&gt;
      &lt;token_data&gt;
        &lt;type&gt;&lt;/type&gt;
        &lt;value&gt;&lt;/value&gt;
        &lt;cardholder_name&gt;&lt;/cardholder_name&gt;
        &lt;exp_date&gt;&lt;/exp_date&gt;
      &lt;/token_data&gt;
    &lt;/token&gt;
  &lt;/B&gt;
  &lt;B&gt;
    &lt;merchant_ref&gt;icici&lt;/merchant_ref&gt;
    &lt;transaction_tag&gt;sdfhisdb&lt;/transaction_tag&gt;
    &lt;transaction_type&gt;balance_inquiry&lt;/transaction_type&gt;
    &lt;method&gt;valuelink&lt;/method&gt;
    &lt;order_number&gt;123&lt;/order_number&gt;
    &lt;amount&gt;2000&lt;/amount&gt;
    &lt;currency_code&gt;&lt;/currency_code&gt;
    &lt;token&gt;
      &lt;token_type&gt;&lt;/token_type&gt;
      &lt;token_data&gt;
        &lt;type&gt;&lt;/type&gt;
        &lt;value&gt;&lt;/value&gt;
        &lt;cardholder_name&gt;&lt;/cardholder_name&gt;
        &lt;exp_date&gt;&lt;/exp_date&gt;
      &lt;/token_data&gt;
    &lt;/token&gt;
  &lt;/B&gt;
&lt;/A&gt;</code></pre>
</div>
</div>
</p>

<p>rying to check the content of xml using the below dataweave but getting output as null B like  Please suggest how to avoid this. as I need to do another point to point mapping from xml to xml for each element but that Mapping is creating an extra map where B is null also.</p>

<p>Please suggest how to avoid this</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>%dw 1.0
%output application/xml
---

A: payload.id.*items mapObject
{
 
       B:$  when $.method=="valuelink"      
      
      otherwise {
       
      }
     }</code></pre>
</div>
</div>
</p>