[xsd-users] Sort of XML "reflection"

Paquette, Patrick PaquetP at navcanada.ca
Wed Nov 18 10:26:37 EST 2009


Hi Boris, 

Boris writes:

> If this is just one type T and one type B (or, maybe a few such types,
> as opposed to the whole object model), then you can customize T to
> contain a multimap of, say, element names to instances and customize
> B to register on its container. In case of B, the container node is
> specified in via c-tors or via the virtual _container() function 
> (defined in xml_schema::type). You will need to override it to do the 
> registration. The only issue with this approach is that B (or T) would
> need to know the element name in order to register on T. One way to do
> this would be to have a static map of std::type_info to element name 
> in T which is manually populated with all the derivations of B and
> their element names (assuming each type is used for one element name).
> 
> We will actually need something similar in order to support 
> native XPath/
> XQuery execution on the object model. In fact, once it is 
> implemented, 
> you could use use one of these languages to implement this. But this 
> is still some time away (a month or two).
> 

Good to know on Xpath/Xquery.  This solution, unfortunately, isn't
generic enough for me.  Someone doing maintenance on the software in the
future is going to add a new element of type B to a T and wonder why
this portion of the program isn't working, to find out they forgot to
add to this static list.

I'll look into serializing to a DOMDocument, and deserialize back to T,
so that I can go find it.  Might not be too efficient...I'm doing this
on somewhere around 10-20 T's, 10 times a second on relatively small xml
fragments of type T, hopefully my target platform can do this fast
enough.

Thanks for answering,
Patrick



More information about the xsd-users mailing list