[xsd-users] How to know the member functions at run time

Boris Kolpackov boris at codesynthesis.com
Mon Apr 3 11:03:33 EDT 2006


Hi Yongsheng,

Zhao, Yongsheng <yongsheng.zhao at nortelgov.com> writes:

> We are writing a framework for users' algorithms. We would like to define
> the algorithms' parameters inside a class using the xml schema. Since the
> parameters' types and names varies with algorithms, we don't want to hard
> code the parameters' names and types in code. We are seeking a way to get
> them dynamically, so that this part of the code can be resued for different
> algorithms, we only need to change .xsd file.

I see. But you will still have some other parts of your code that are aware
of each algorithm's parameters and types, right? Otherwise there is no
way to execute those algorithms.

From your previous emails I gathered that you want (or need) to use some
other data structure to hold those parameters and therefore need to
generically populate this structure from data types generated by xsd.
Is that about right? If so then I see two potential solutions:

1. If you can pass xsd-generated types around instead of your custom
   data structure, then you could use generic xml_schema::type pointer
   or reference in your generic code. The non-generic code will then
   cast it to the appropriate algorithm type and extract parameters.

2. You could extract parameters in your generic code and store them
   in your data structure as <string, xml_schema::type*> pair list
   (or map). The non-generic code will then cast those xml_schema::type
   pointers to parameter types.


> You mentioned we could iterate DOM elements, do you mean the DOM for
> the xml file or for the xsd file?

I meant for the XML file.

> If we can iterate the DOM element for the xsd file to get the member
> functions, can we also get the members' types there?

Since XML Schema is XML, you could load it into a DOM document and
find out element/attribute names and their (XML Schema) types. I
don't, however, see how it could be useful at runtime. I think
it is important to realize that in C++ there is generally no way
to call a function having its name in a string or creating an
instance of a type having this type's name in a string.

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060403/26aa0ffd/attachment.pgp


More information about the xsd-users mailing list