String typeName = mdSchema.getElementType(el.getQualifiedName(),parentName);
if(Log.isDebugEnabled(Geonet.EDITORADDELEMENT))
Log.debug(Geonet.EDITORADDELEMENT,"#### - type name = " + typeName);
MetadataType type = mdSchema.getTypeInfo(typeName);
if(Log.isDebugEnabled(Geonet.EDITORADDELEMENT))
Log.debug(Geonet.EDITORADDELEMENT,"#### - metadata tpe = " + type);
//--- collect all children, adding the new one at the end of the others
Vector<Element> children = new Vector<Element>();
for(int i=0; i<type.getElementCount(); i++) {
List<Element> list = getChildren(el, type.getElementAt(i));
if(Log.isDebugEnabled(Geonet.EDITORADDELEMENT))
Log.debug(Geonet.EDITORADDELEMENT,"#### - child of type " + type.getElementAt(i) + " list size = " + list.size());
for (Element aChild : list) {
children.add(aChild);
if(Log.isDebugEnabled(Geonet.EDITORADDELEMENT))
Log.debug(Geonet.EDITORADDELEMENT, "#### - add child " + aChild.toString());
}
if (qname.equals(type.getElementAt(i)))
children.add(child);
}
//--- remove everything and then add all collected children to the element to assure a correct position for the
// new one