DR-103 Building XDoc from key-value pairs can build wrong document.

Reviewed by ArneC
Ticket: http://youtrack.developer.mindtouch.com/issue/DR-103