[xsd-users] Re: accessing parsed values

Boris Kolpackov boris at codesynthesis.com
Wed Nov 11 12:23:50 EST 2009


Hi Dmitry,

In the future please send technical questions like these to the
xsd-users mailing list (which I've CC'ed) instead of to me directly.
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. See also the
posting guidelines:

http://www.codesynthesis.com/support/posting-guidelines.xhtml


Dmitry Kekelidze <dkekel at gmail.com> writes:

> I'm writing a class to use parsed values from xml. How can I access them?
> For example in print imp I have such code:
> void samplesDescriptionType_pimpl::
>   documentId (const ::std::string& documentId)
>   {
>     std::cout << "documentId: " << documentId << std::endl;
>   }
> and I need to acces documentId directly. Can You help me with this?

The C++/Parser mapping that you are using does not store the data
that is extracted from XML so the callback functions are the only
place where the data is available. Depending on your requirements,
you may want to store the data in your own data structure. The 
mapping provides a mechanism for assembling such an "object model"
from the XML document as it is being parsed. See Chapter 4, "Type 
Maps" in the C++/Parser Getting Started Guide for more information
on how to do this:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#4

Alternatively, you may want to consider using an in-memory mapping,
such as C++/Tree, that automatically creates the object model which
can then be accessed directly.

Boris



More information about the xsd-users mailing list