Page 1 of 1

'Format and indent' does not work with leading spaces

Posted: Tue Sep 06, 2011 3:23 am
by csalsa
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.

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

Posted: Tue Sep 06, 2011 12:14 pm
by Radu
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