Hi, Brian...
Given your requirements for somewhat finer control over the markup, you
might consider running the DOM document through an XSLT transform to get the
result you want. This would be mostly an identity transform, but would
allow you to control settings such as the presence of the XML declaration.
You'd also be able to override specific things, such as suppressing
attributes that correspond to their default values. It might be somewhat
tedious to generate the overrides for default attributes, depending on the
size of your DTD/Schema, though there are ways this could be automated, such
as an XSLT transform of an XML Schema or using ACL to access such
information in a DTD.
-Brandon 🙂