OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   [xml-dev] Handling of empty content and white space-only content?

[ Lists Home | Date Index | Thread Index ]


If you validate your XML with a DTD, then you can specify whether an
element contains only other elements, only parsable-character-data,
or both (mixed-content).

If an element is declared to contain only other elements, then
whitespace is not significant. If, however, an element is declared
to contain parsable-character-data, then all whitespace is
significant whether or not it comes directly after or directly before
an element tag.

If you don't validate your XML with a DTD, then all whitespace is
significant.

When I say that whitespace is significant, then I'm not referring to
the  whitespace within an element tag:
< foo /> and <foo/> are equivalent.

Now, whether whitespace is significant or not, the XML specification
says:
"An XML processor MUST always pass all characters in a document that
 are not markup through to the application.
 A validating XML processor MUST also inform the application which of
 these characters constitute white space appearing in element
 content."
This means that you'll always have all the whitespace to work with,
whether or not it is "significant".

The XML specification also says something about a xml:space attribute.
As I understand it, when this attribute has a value of "preserve",
then XML processors/applications should always treat whitespace as
significant.

Regarding empty elements:
An empty element can be written like <foo></foo> or <foo/>, they are
both equivalent. I assume that no XML processor will make a difference.




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS