[xsd-users] XML Object to String/Text

Paddy Vishnubhatt Paddy.Vishnubhatt at 3leafnetworks.com
Wed Feb 21 23:33:40 EST 2007


Hi Boris, Thx for all the help, I could finally get the String output to work based on yr code/examples. 
The following is the way I could get it all to work:
 
        xml::dom::auto_ptr<xercesc::DOMDocument> doc (create( // create-taken from the link you sent below.
                                                            request.objectName(),
                                                            "http:// <http://0> ...",
                                                            "e"));
        xercesc::DOMElement& root (*doc->getDocumentElement());
        root << request;
        std::ostringstream ostr;
        serialize(ostr, *doc, "UTF-8"); // taken from the link you sent.
        std::string str = ostr.str(); 
        LOG4CXX_DEBUG(logger(), str);

Thx again for all the prompt help and pls keep up the good work.
 
Feature request/suggestion: Can this all be packaged into one API? I don't know how the Java framework managed to pull this off but it is likely that they may have hidden all the above (the create() and serialize() functions and the use of ostringstream, etc) 'under the covers' and offered a 'blanket' API and called it xmlText(). If you can do the same in some near (or not so distant) future, it'll help many who're doing distributed/x-platform (XDR-like) where stringifying XML to strings and passing data is an easy means to exchange data.
--

________________________________

From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Wed 2/21/2007 8:54 AM
To: Paddy Vishnubhatt
Cc: Boris Kolpackov; xsd-users at codesynthesis.com
Subject: Re: [xsd-users] XML Object to String/Text



Hi Paddy,

Paddy Vishnubhatt <Paddy.Vishnubhatt at 3leafnetworks.com> writes:

> Q: Is there an API that I can generically use to create DOMDocument
> objects from any XSD-driven object?

One (easy) way would be to create a function template from the code
I sent you in another email.

A more elaborate method which can serialize any type via
xml_schema::type (base for all generated types) is described in this
message:

http://www.codesynthesis.com/pipermail/xsd-users/2006-August/000501.html

Note that in the latest version the "type_name_*" names were changed to
"type_serializer_*".


hth,
-boris





More information about the xsd-users mailing list