'Format and indent' does not work with leading spaces

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
csalsa
Posts: 97
Joined: Tue Apr 22, 2008 9:31 am

'Format and indent' does not work with leading spaces

Post by csalsa » Tue Sep 06, 2011 3:23 am

I found that if spaces are before the XML document type declaration, it makes the XML document 'not well formed'. In addition the action 'Format and indent' does not work.

Leading spaces are superfluous but should they make the XML document 'not well formed'?

And could the 'Format and Indent' action add in a first step to remove leading spaces? So regardless of leading spaces make the XML document invalid or not, they are first removed and then the action 'Format and Indent' succeeds.

I know this is a small thing. It is that have been cutting and pasting XML from run-time logs and I always manage to paste leading spaces that I manually must remove.

Radu
Posts: 7207
Joined: Fri Jul 09, 2004 5:18 pm

Re: 'Format and indent' does not work with leading spaces

Post by Radu » Tue Sep 06, 2011 12:14 pm

Hi,

Spaces are allowed before the document type declaration.
But they are not allowed before the XML declaration:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
The production in the XML specification:

http://www.w3.org/TR/xml/#sec-prolog-dtd
specifies that if the xml declaration is present, no other character must precede it. This is useful for parsers to determine the encoding of the XML file.

If you add any space before the declaration, it makes the XML document not wellformed.
The format and indent needs the XML document to be well formed in order for it to work. Also the action does not format and indent spaces or other content which occurs before the root element, they are preserved untouched.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply