[xsd-users] Re: invalidated iterators

Boris Kolpackov boris at codesynthesis.com
Tue Jul 28 03:08:09 EDT 2009


Hi Brian,

In the future please send technical questions like these to the
xsd-users mailing list (which I've CC'ed) instead of to me directly.
For more information, see the Posting Guidelines:

http://www.codesynthesis.com/support/posting-guidelines.xhtml


B Hart <bhartsb at gmail.com> writes:

> Hi Boris,
> 
> In my XSD code it seems that when I use a parsing function to create an
> object model of my XML doc, and then subsequently change some element value
> and re save the XML doc, if I have a sequence iterator it becomes
> invalidated.  If I change the name of the XML file that I save then the seq
> iterator does not seem to be invalidated.  However, would prefer to not have
> to create a second file.  Any ideas???

The object model is passed as a const reference and is not modified by
serialization functions. So I don't see how serializing the object model
can invalidate any iterators that point to it.

However, the following scenario can lead to the behavior that you are
observing: You obtain an iterator for a sequence somewhere in the 
object model. In another part of your program you add or remove some
elements from this sequence. In this case, the iterator that you
first obtained will be invalid.

If you can't find the source of the problem, feel free to send a test
case that reproduces this and I will take a look.


Boris


[The rest of the email follows for reference.]
 
> Thanks,
> 
> Brian Hart
> 
> Here is a bit of the code:
> 
> 
> LA_Config_T::InputProperties_sequence& ips(la->InputProperties());
> 
> ...
> 
> for(LA_Config_T::InputProperties_iterator LA_iIt(ips.begin()); LA_iIt!=
> ips.end(); LA_iIt++){
> ...
> 
> xml_schema::namespace_infomap map;
> map[""].name = "";
> map[""].schema = "LA_Config.xsd";
> std::ofstream ofs(la->LAConfigXMLFile().c_str());
> LA_Config(ofs, *la, map);
> }  //error happens here when for loop iterator is accessed




More information about the xsd-users mailing list