How to convert hook_xmlsitemap_links to xmlsitemap 6.x-2.x API?
There doesn't seem to be hook anymore to return links for further processing, but
 adding and deleting links is done with calls to xmlsitemap_link_save and xmlsitemap_link_delete(_multiple)

I implemented a hook_xmlsitemap_index_links, which normally is only called when the command drush xmlsitemap-index is issued:

function my_xmlsitemap_index_links($limit) {
  $sql = "SELECT x.id FROM {xmlsitemap} x WHERE x.type = 'my'";
  $query = db_query($sql);
  $indexed = xmlsitemap_db_fetch_col($query);
  //there isn't a lot of stuff, it fits in memory, but fetching it is costly.
  $indexed = array_flip($indexed);
  $mystuff = __my_get_stuff();
  $i = 0;
  foreach ( $mystuff as $thing ) {
    if ( !isset($indexed[$thing-&gt;id]) ) {
      # new thing
      xmlsitemap_link_save(__my_make_xmlsitemap_link($thing), $thing-&gt;id);
      $i++;
    }
    unset($indexed[$thing-&gt;id]);
    if ( $i == $limit )
      return;
  }
  #Done indexing new stuff;
  if ( $indexed ) {
    $deleted = array_flip($indexed);
    xmlsitemap_link_delete_multiple(array('type'=&gt;'my', 'id'=&gt;$deleted));
  }
}


I'm still puzzling on what to return from my hook_xmlsitemap_link_info. It's not at all clear when those callbacks are called. 


The process callback is useless for this usecase; xmlsitemap has no way of knowing any foreign IDs.
The rebuild callback is afaik only called by drush and manual action, not a means of keeping the links up to date, but it remains unclear if such a callback is required or optional (although xmlsitemap_custom seems to manage without one)
The settings callback is still a mistery to me, but it's used for the admin.


This hook_xmlsitemap_link_info with my_xmlsitemap_index_links as rebuild callback, makes my module reindex when I issue a rebuild command from the admin.

function my_xmlsitemap_link_info() {
  return array(
    'my' =&gt; array(
      'label' =&gt; t('My Stuff'),
      'xmlsitemap' =&gt; array(
        'rebuild callback' =&gt; 'my_xmlsitemap_index_links',
        ),
      )
    );
}


I ended up implementing a hook_cron that periodically calls my_xmlsitemap_index_links, to keep it in sync.

I might update my hook_load, to issue a xmlsitemap_link_delete on failed loads (404's).