XenoAmess
XenoAmess

Reputation: 375

xml:space="preserve" effect on space between XML attributes?

I know that

<a xml:space="preserve">
<b></b>
</a>

is different than

<a xml:space="preserve">
<b>  </b>
</a>

However, what about

<a xml:space="preserve">
<b c='c'></b>
<c   />
</a>

and

<a xml:space="preserve">
<b     c='c'></b>
<c />
</a>

I can't find documentation about how xml:space="preserve" affects these cases.

Upvotes: 6

Views: 20889

Answers (1)

kjhughes
kjhughes

Reputation: 111521

The xml:space="preserve" directive says that space within element content is significant.1

It does not affect whitespace within start tags, which is significant only to the extent that its presence is needed to separate attributes from themselves and from the name of the element:

[40] STag ::= '<' Name (S Attribute)* S? '>'

Note that the S production requires one whitespace character and allows multiple:

[3] S ::= (#x20 | #x9 | #xD | #xA)+

1 The default (and only other allowed setting), xml:space="default", allows indentation (pretty-printing) of XML without changing significance.

Upvotes: 12

Related Questions