[xsd-users] sorting of a sequence of elements when IDs are contained, duplicate_id exception

Jan Klimke jan.klimke at hpi.uni-potsdam.de
Thu Feb 12 08:23:13 EST 2009


Hi all,

i would like to sort a sequence which was extracted from xml. Therefore
i defined a comparison function like this

bool TourTool::compareTourSectionBySectionNumber(
gml::FeaturePropertyType& sec1,gml::FeaturePropertyType& sec2 ){
     return
(static_cast<TourSectionType*>(sec1.getFeature())->getSectionNo() <
static_cast<TourSectionType*>(sec2.getFeature())->getSectionNo());
}

The problem is when i call

std::sort(tour->getTourSection().begin(), tour->getTourSection().end(),
compareTourSectionBySectionNumber);

where tourSection is a sequence of gml:FeaturePropertyType, a
duplicate_id exception is thrown. This probably happens because of the
gml:id of the entities is copied when a position switch in the sequence
is necessary.

Is there another way to sort such a sequence without throwing this
exception ?

Regards,
Jan




More information about the xsd-users mailing list