[xsd-users] Need help !!!

Picsou en Bretagne breizh_picsou at yahoo.fr
Tue Jun 26 05:14:31 EDT 2007


sorry to disturb you again but I have problems using your sample.
  In my project, first I'm reading all elements and I'm storing reference of this elements in a list.
  Then I'm reading the list and trying to find parent of this element to find the "path".
   
  For example, this is a sample of my problem :
   
  for ( LIST::iterator iter (myList.begin()); iter !=myList.end(); ++iter) {
   
  A & a = *iter;
   
     cerr << endl
    << "ELEMENT: " << a.NAME() << endl ;
   
  B* b = static_cast (a._container ());
     cerr << endl
    << "PARENT : " << b->NAME() << endl ;
   
  }
   
  but the result is bad : for "b",  I see name of  "a"
   
  thxs a lot 
   
  MIKE
  

Boris Kolpackov <boris at codesynthesis.com> a écrit :
  Hi,

Picsou en Bretagne 
writes:

> sorry for the reply and thanks for your solution but is it possible to
> have the parent object to have attributes for exemple because I'm not
> sur but this solution bring the name of the element only , No ?

You will need to cast the returned (generic) pointer to a concrete
type before you can do anything useful with it. For example if we are
iterating over authors of a book in the library example (using 2.3.1
syntax):


catalog& cat = ...

for (catalog::book::iterator bi (cat.book ().begin ());
bi != cat.book ().end ();
++bi)
{

for (book::author::iterator ai (bi->author ().begin ());
ai != bi->author ().end ();
++ai)
{
author& a = *ai;

book* b = static_cast (a._container ());
catalog* c = static_cast (b->_container ());
}
}

hth,
-boris


       
---------------------------------
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 


More information about the xsd-users mailing list