[xsd-users] Getting at the autopointers
James Boyden
jboyden at geosci.usyd.edu.au
Wed Nov 16 07:23:10 EST 2005
On Wednesday, Nov 16, Boris Kolpackov wrote:
> If I understood you correctly, you want to "detach" some sub-trees from
> the complete document tree and manage them separately. The only way that
> I can think of is by making a copy of the nodes that you are interested
> in (a copy of all the "sub-nodes" will be made automatically). E.g.,
> suppose you have the following schema:
>
> <complexType name="Foo">
>
> ...
>
> </complexType>
>
>
> <complexType name="Bar">
> <sequence>
> <element name="foo" type="Foo"/>
>
> ...
>
> </sequence>
> </complexType>
>
>
> Then you can do something like this:
>
> Bar& b = ...
>
> auto_ptr<Foo> f (new Foo (b.foo ())); // Make a copy.
Hi,
I admit I haven't yet looked too closely at the XML schema polymorphism
features used to handle things like substitution groups, but if there's
C++ polymorphism involved, wouldn't
auto_ptr<Foo> f (new Foo (b.foo ())); // Make a copy.
be better expressed as something like
auto_ptr<Foo> f (b.foo ().clone ()); // Make a clone.
using the "virtual constructor" idiom [1]?
(I note that in the file "schema.hxx" generated by xsd for the
"cxx/tree/polymorphism" example, the classes 'person_type',
'superman_type', 'batman_type' and 'instance_type' all have a function
'_clone', but this function is clearly intended for internal use only,
plus it takes two arguments which I don't understand, so I'm going to
assume that it's not the solution to this problem.)
jb
[1] "virtual constructor" idiom:
http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8
More information about the xsd-users
mailing list