Bug #2199: Better formatting for undefined elements
(cherry picked from commit 2f45e5c7e9ddb7d8dd7c10eec363499ebf6f8aeb)