Solution to migrate a field collection My requirement is to migrate  content nodes in xml format to drupal 7 content type fields.The xml contains a node which has to be field collection in drupal.I know how to migrate field which are enity references and term references.But i am new to field collection migration.I am using drupal migrate contrib module for migration.
The field collection node in my xml file.

&lt;myphotos_grid grid="true"&gt;&lt;![CDATA[&lt;rows&gt;
  &lt;row rowID="1"&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo-name&lt;/theName&gt;
      &lt;value&gt;photname1&lt;/value&gt;
    &lt;/rowAttribute&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo-credit&lt;/theName&gt;
      &lt;value&gt;my credit&lt;/value&gt;
    &lt;/rowAttribute&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo&lt;/theName&gt;
      &lt;value&gt;
      &lt;attachment id="1009343343"/&gt;
      &lt;/value&gt;
    &lt;/rowAttribute&gt;
  &lt;/row&gt;
  &lt;row rowID="2"&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo-name&lt;/theName&gt;
      &lt;value/&gt;
    &lt;/rowAttribute&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo-credit&lt;/theName&gt;
      &lt;value/&gt;
    &lt;/rowAttribute&gt;
    &lt;rowAttribute&gt;
      &lt;theName&gt;photo&lt;/theName&gt;
      &lt;value&gt;
      &lt;attachment id="4432434344"/&gt;
      &lt;/value&gt;
    &lt;/rowAttribute&gt;
  &lt;/row&gt;
&lt;/rows&gt;]]&gt;&lt;/myphotos_grid&gt;


I am writing a base class for my content types migration by extending XMLMigration class and it defines the migration source files and destination.Also i am writing corresponding classes for each content type which defines the field mapping by extending base class.

Above xml grid node in xml which has to be migrated to to field collection in my content type X in drupal 7 site.

My queries

Whether i need to write a seperate class for field collection extending my custom content type X migration class or adding the field mappings for field collection in the custom content type X migration class?
Whcih is the best standard to migrate field collection in drupal?

I am new to this field collection migration,please help,Also very sorry for my english.
I think you're on the right track. If I'm understanding your question, you won't need to add an extra class.  Instead, you'll want to use your existing Migration class's complete() method, which is called after the node has been created.  Within complete(), you can then use entity_create to create your field collection and entity_metadata_wrapper around your newly migrated node to set a reference to your field collection entity.

In psuedocode,

public function complete($entity, stdClass $row) {
  fc_entity = entity_create(...) 
  $ewrapper = entity_metadata_wrapper('node', $entity);
  $ewrapper-&gt;fc_ref_field-&gt;set( $fc_entity-&gt;nid );
  $ewrapper-&gt;save();
}   


Or something thereabouts. When in doubt, "whatever works" is the correct standard for migration code. Hope that helps get you started!