[xsd-users] Re: xsd-users Digest, Vol 32, Issue 14 serialization without pretty print

Gordon Kramer gkr at as-guides.com
Tue Mar 11 07:20:23 EDT 2008


Hi,
I am also interested in switching off pretty print dynamically.

> > 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
> 

having had a look at the code it doesn't look too complicated by
introducing another serialisation flag no_pretty_print.
please find attached a patch for this proposal
I did not add a test for this feature yet.

Gordon


-------------- next part --------------
A non-text attachment was scrubbed...
Name: xsd_no_pretty_print.patch
Type: text/x-patch
Size: 2225 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20080311/2094cf3d/xsd_no_pretty_print.bin


More information about the xsd-users mailing list