[xsd-users] Re: [xsde-users] how to insert/remove elements?

Boris Kolpackov boris at codesynthesis.com
Wed Feb 13 15:00:43 EST 2008


Hi Gennady,

In the future please keep your replies CC'ed to the xsd-users mailing
list. This way other developers who may have experienced a similar
problem can provide you with a solution. Plus questions and answers
will be archived and available to others with similar problems.


Gennady Khokhorin <gok at aerometric-ak.com> writes:

> One tiny question/wish: streaming out xml with std::ofstream created an
> extra carriage return symbol after each element:
> <?xml version="1.0" encoding="ISO8859-1" standalone="no" ?>
> <hello>
>
>   <greeting>Hello</greeting>
>
>   <name>its me</name>
>
> </hello>
>
> How to drop it?

XSD uses DOMWriter provided by Xerces-C++ to serialize to XML.
It turns the format-pretty-print feature on by default which
produces the result you see (BTW, I believe it adds extra new
lines only for element that are directly under the root so real
documents with several nesting levels actually look better with
these extra newlines than without them).

You only other option is to turn pretty-printing off altogether
in which case you will get unformatted XML. To do this you will
need to set the DOM-to-XML serialization stage yourself and switch
the format-pretty-print feature off on the DOMWriter object. For
more information see Q3.2 in the C++/Tree Mapping FAQ:

http://wiki.codesynthesis.com/Tree/FAQ

As well as the Xerces-C++ DOMWriter documentation:

http://xerces.apache.org/xerces-c/program-dom.html#DOMWriterFeatures

Boris




More information about the xsd-users mailing list