Hi Alessandro,

Alessandro Chiarini <[EMAIL PROTECTED]> writes:

> How the precision is handled by XercesC? 

It is not. Xerces-C++ gives raw representation of XML: elements, attributes,
and text.


> Is this done transparently by the user?

Yes, it is user's responsibility to convert between text and a floating
point type.


> Is there some documentation regarding this issue?

Serialization of floating point numbers to decimal form is actually
a very tricky issue once you need to support a round trip (e.g.,
text->double->text->double) without loss of information. It took us
a long time to figure out various nuances. If you are interested,
you can take a look at how we do it in CodeSynthesis XSD (see the link
in the signature below). Also the following paper is quite useful in
understanding of the issue involved:

http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf


> Second question comes now. Is there a way to configure XercesC to serialize
> floating point numbers with a fixed decimal precision? Is there the way to
> format the serialization string via the API?

We use the standard C++ streams for that (std::ostringstream).

Boris

-- 
Boris Kolpackov, Code Synthesis Tools   http://codesynthesis.com/~boris/blog
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

Reply via email to