%dw 2.0
input payload application/xml
output application/xml
fun mapKeys(element, func) =
  element match {
    case obj is Object -> obj mapObject {
      (func($$)) @((if($.@?) $$.@ else {}) ): mapKeys($, func)
    }
    else -> element
  }
---
mapKeys(payload, ((key) -> (lower(key))))