Skip to main content

XML encoding issues: blank screen in GeoNetwork


This week's challenge: a head-scratching case of blank metadata records turned out to be an encoding problem.

The situation: I processed a group of XML metadata files that looked fine and imported into GeoNetwork without issue.  I could view the records, but when I tried to edit one, I was presented with a blank screen.

One issue was that the files were using this encoding: <?xml version="1.0" encoding="ISO-8859-1"?>. I changed ISO-8859-1 to UTF-8, and reimported the files. This worked for some files, but several still presented blank pages.

The diagnosis: The main problem was that the files contained illegal characters that remained after changing the encoding.  A few could be picked out in Oxygen, but many remained invisible.  

The solutions: Find and delete problematic ASCII codes.

Solution #1: Terminal Command

Enter this command: grep -n '[[:cntrl:]]' *
Then view the offending XML using a terminal text editor such as vim or emacs. The characters should be visible. Delete them!

Solution #2: Zap Gremlins

This is a utility available in TextWrangler (free), BBEdit, or Sublime Text (Windows).  It should remove any problematic ASCII codes.