[xsd-users] copying IDREF elements classes

Boris Kolpackov boris at codesynthesis.com
Thu May 31 03:38:44 EDT 2012


Hi Omkar,

Omkar Wagh <owagh at tower-research.com> writes:

> I want to be able to copy IDREF structs.
>
> <xs:complexType name="some_unit">
> <xs:sequence>
> <xs:element name="some_ref" type="IDREF" />
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="some_bigger_unit">
> <xs:sequence>
> <xs:element name="unit1" type="some_unit" />
> <xs:element name="unit2" type="some_unit" />
> </xs:sequence>
> </xs:complexType>
>
> Now, I'm using xsd and cxx-tree and I want to be able to construct  
> instances of class some_bigger_unit from instances of class some_unit.

I am not sure what the issue is. You can do:

some_unit u1 ("id1"), u2 ("id2);
some_bigger_unit bu (u1, u2);
some_bigger_unit bu2 (bu.unit2 (), bu.unit1 ());

> However, thanks to the auto_pointer thing, if I do that, the original  
> class looses ownership of the pointer to the referenced element (or so
> I believe).

I am not sure what you mean here? Are you detaching some_unit instance
from some other tree? That's the only way to get an auto_ptr in C++/Tree.
I think it will be the best if you show some sample code that doesn't
work for you (always a good idea).

Boris



More information about the xsd-users mailing list