XBinder can help you create documents that follow the W3C Canonical XML Recommendation. XBinder for C and C++ have a -c14n command line option for this purpose. For Java and C#, however, you programmatically turn on Canonical XML support by invoking the method setCanonicalXML() on your XBXmlEncoder object.
Turning on Canonical XML support has the following effects:
Namespace declarations will appear before attributes.
Namespaces declarations and attributes will be sorted.
All start tags will have a matching end tag.
Character escaping will be done according to Canonical XML (this is actually the standard behavior).
The indendation and line terminators that are normally added to the encoding to improve readability will be omitted.
The XML prolog will be omitted ("<?xml version="1.0" ...?>").
Additionally, you must take some care to comply with the Canonical XML recommendation. You must use UTF-8 character encoding (the zero argument constructor for XBXmlEncoder does this). You must not add superfluous namespaces into your complex-type objects. Finally, for mixed content and xml:any types (where you provide raw XML that passes directly into the output), you must ensure that the raw XML you provide complies with the Canonical XML recommendation.