Discarding whitespace, or deciding that an element is in some sense "empty" and should be treated differently, is an obviously application-specific and element-specific decision: a parser should conservatively preserve whitespace in order to support any possible usage.
As a partial solution, you might want to support the xml:space attribute (§2.10, "White Space Handling", in the XML recommendation):
Quote:
The value "default" signals that applications' default white-space processing modes are acceptable for this element; the value "preserve" indicates the intent that applications preserve all the white space. This declared intent is considered to apply to all elements within the content of the element where it is specified, unless overridden with another instance of the xml:space attribute.
Collapsing or removing whitespace-only text nodes might be the default for your library, with "preserve" allowing for an override.
Note that you can often add "xml:space='preserve'" to the appropriate elements implicitly with a DTD or XML Schema, whitout altering and bloating the documents.