[xsd-users] How to build an object process graph with custom types
Florian Paul Schmidt
fschmidt at techfak.uni-bielefeld.de
Thu May 12 16:24:47 EDT 2011
On 05/12/2011 04:08 PM, Bo Ba wrote:
>
> I am not sure I follow you on the difference between "requested
> datastructure" and "custom in-memory representation of the XML document",
> however, it seems to me that you have a nice design using factories for each
> type. Could you explain the difference above? Do you have a runnable
> example, like xsd's?
>
> Thanks.
>
> Bo
Hi again.
Well, my software uses XSD, too. Let me explain a bit more. Say you have
some Type X
namespace mystuff {
struct Y {
// ...
};
struct X {
Y m_Y;
// ...
};
} // namespace
And corresponding XSD schema types in some .xsd file (an example in my
CBF stuff would be e.g. CBF::PrimitiveController and the corresponding
XSD schema type (see schemas.xsd)). Now the XSD compiler generates a
parser AND a C++ class for each of the types in your schema, in this
case X and Y, let's say we have XSD generate them in their own
namespace, let's say schema. So XSD generates code for the classes
schema::X and schema::Y. And when the generated parser parses a valid
XML file corresponding to this schema, it also creates the correct
instances of schema::X and schema::Y. But what we really want is to have
mystuff::X and mine::Y created. Since this task cannot be completely
automated, there is some manual labor involved in this (for example
mystuff::X needs to do something with network connections or whatever).
So the classes generated by XSD really only represent the XSD schema and
the parser generates an object tree of these generated classes when it
parses a valid XML file, but does not produce an object tree of your
real target objects (in your case the nodes of your dataflow graphical
language).
The XML factory stuff in CBF is used for exactly this last step. It just
makes some repetitive tasks easier.
Did i confuse you even more now? :D
Regards,
Flo
More information about the xsd-users
mailing list