W3C home > Mailing lists > Public > public-webapi@w3.org > July 2006

Re: DOM3 Core clarification: isElementContentWhitespace?

From: Cameron McCormack <cam@mcc.id.au>
Date: Sat, 8 Jul 2006 11:36:36 +1000
To: public-webapi@w3.org
Message-ID: <20060708013636.GA14810@port.mcc.id.au>

Hi Alex.

Alex Vincent:
> I took a look at DOM 3 Core's isElementContentWhitespace definition,
> and I don't fully understand how it's supposed to work.  I thought at
> first glance it meant "Does this text node
> contain only whitespace?", but a fellow developer tells me it isn't that 
> simple.
> Could I get some clarification on what it is supposed to mean?

DOM 3 Core refers to the [element whitepsace content] property in XML
Infoset, which says:

  A boolean indicating whether the character is white space appearing
  within element content (see [XML], 2.10 "White Space Handling"). Note
  that validating XML processors are required to provide this
  information. If there is no declaration for the containing element, or
  there are multiple declarations, this property has no value for white
  space characters. If no declaration has been read, but the [all
  declarations processed] property of the document information item is
  false (so there may be an unread declaration), then the value of this
  property is unknown for white space characters. It is always false for
  characters that are not white space.

So firstly Text.isElementContentWhitespace can only return true if the
processor is in validating mode, and all of the DTD/schema has been
read, and the text node does contain element content whitespace.  XML
1.0 Third Edition defines element content as:
  An element type has element content when elements of that type MUST
  contain only child elements (no character data), optionally separated
  by white space (characters matching the nonterminal S).

(I assume also that this definition also includes elements that cannot
have any child elements, too, but it’s maybe not clear just from that
sentence above.)

So basically if the text node contains only whitespace, and the
processor is validating, and according to the schema the parent element
of the text node has a content model that allows only elements, then the
method must return true.

Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Saturday, 8 July 2006 01:37:02 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:21 UTC