[xsd-users] issue creating document in memory

Boris Kolpackov boris at codesynthesis.com
Tue Jan 9 11:28:33 EST 2007


Hi Russ,

Please keep xsd-users CC'ed to your future replies. This way others
who may have a similar problem will be able to find the answer in
the archives.

Russ Johns <johns at lanl.gov> writes:

>     It has been a while since I was a heavy c++ programmer (~1995).  From my
>    quick glance  at the default constructor:
>
>       SwordInput::
>        SwordInput ()
>        : ::xml_schema::type (),
>        _xsd_elementlist_ (::xml_schema::flags (), this),
>        _xsd_materiallist_ (::xml_schema::flags (), this),
>        _xsd_objectlist_ (::xml_schema::flags (), this),
>        _xsd_rotationlist_ (::xml_schema::flags (), this),
>        _xsd_volumelist_ (::xml_schema::flags (), this),
>        _xsd_world_positions_ (::xml_schema::flags (), this),
>        _xsd_energies_ (::xml_schema::flags (), this),
>        _xsd_runinfo_ (::xml_schema::flags (), this)
>        {
>        }
>
>    it looked like it was calling the default constructors on the nested
>    elements.

If you check the type of _xsd_elementlist_, you will see that is not
of type ElementList but rather of one<ElementList>, where 'one' is
a container, similar to auto_ptr.


>    The actual lists (e.g. SWORD::input::ElementList::element::container)
>    created by xsd-  are they STL vectors? with STL iterators?

They are not of std::vector though they use std::vector underneath.
The sequence container implements complete std::vector interface with
iterators conforming fully to the STL iterator interface (random access
in this case) so you can use sequence containers as if they were
std::vector's.

>    Understood-  the final app will have a number of routines to perform the
>    job of populating the tree,  so it would be a little difficult to grow the
>    tree completely from the bottom.

That's one of the reasons that persuaded us to add the
--generate-default-ctor option. But you must be careful since the
interface no longer enforces creation of fully-initialized tree nodes.


>      si->elementlist (SWORD::input::ElementList ()) // initialize element
>      list
>
>      SWORD::input::ElementList& el (si->elementlist()); // get element list
>      ref
>
>    This works well,  thanks-  I I just use the reference operator, (i.e. I
>    skip the initilizer) it makes it past the original error location but
>    fails the first time I try to add an element to the element list.

You *do* need to initialize the elementlist. The first line is not
optional.


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/20070109/4d29206b/attachment.pgp


More information about the xsd-users mailing list