W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2003

whitespace reality check: when is whitespace significant in element-only content

From: Paul Kiel <paul@hr-xml.org>
Date: Mon, 26 May 2003 15:34:50 -0400
Message-ID: <004001c323bd$dfaa58e0$6401a8c0@pkiel2>
To: <xmlschema-dev@w3.org>
Perhaps I am suffering from reality distortion, but I wanted to ask a simple question.  When is whitespace significant in element-only content?

An example (line breaks and spacing intentional):
The element "Parent" is defined as an element-only content consisting of the child element "Child".   The "Child" element is optional.

Example instance 1:
<Parent>
     <Child/>
</Parent>

Example instance 2:
<Parent>
 </Parent>

I know that Example instance # 1 is valid - and all parsers agree.  The whitespace in between the end of the openning <Parent> and the beginning of the <Child> element (a line break and a few spaces) is ignorable.  

On Example instance # 2, there is one parser that says the white space is significant, and therefore not valid.  Most of the parsers say it is valid.  Is the whitespace in Example 2 significant?  Does it prevent validation?  (even though it is the same whitespace that is in Example 1).

The XML spec says:
See [44] in:

http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags

"The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag."

This leads me to believe that  <Parent></Parent> or <Parent/> are acceptable.  But that would mean Example # 2 is not valid (and most parsers are wrong).

Applying the "smell test" - it just seems illogical that the same whitespace in # 2 as in # 1 would prevent validity.

Can someone please give me a reality check here?

Thanks folks,
In Need Of A Vacation
Received on Monday, 26 May 2003 15:29:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:37 GMT