Ignorable White Space

Another special case that really isn't all that special is white space in element content, sometimes misleadingly called ignorable white space . This is white space in an element whose element declaration specifies that it can contain only child elements and not PCDATA. For example, suppose the PhoneNumber element has the following declaration.

 <!ELEMENT PhoneNumber (CountryCode, AreaCode, Number)> 

Now consider the valid PhoneNumber element below.

 <PhoneNumber>   <CountryCode>01</CountryCode>   <AreaCode>212</ AreaCode >   <Number>555-1234</ Number > </PhoneNumber> 

Because the DTD says this element can only contain these three child elements, the white space is ignorable. It is assumed to exist only for formatting and not to have any real purpose. Nonetheless, the parser will still report all of it to the client application. In most APIs, there will be no distinction between this white space and any other nonignorable white space. The notable exception here is SAX. SAX will pass this white space to the ignorableWhiteSpace() method rather than to the characters () method, so the client application can distinguish ignorable from nonignorable white space.

Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net