function tripal_pub_PMID_parse_authorlist

2.x tripal_pub.PMID.inc tripal_pub_PMID_parse_authorlist($xml, &$pub)
3.x tripal_chado.pub_importer_PMID.inc tripal_pub_PMID_parse_authorlist($xml, &$pub)
1.x PMID.inc tripal_pub_PMID_parse_authorlist($xml, &$pub)
1 call to tripal_pub_PMID_parse_authorlist()
tripal_pub_PMID_parse_article in tripal_pub/includes/importers/PMID.inc

File

tripal_pub/includes/importers/PMID.inc, line 770
Tripal Pub PubMed Interface

Code

function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
  $num_authors = 0;

  while ($xml->read()) {
    $element = $xml->name;

    if ($xml->nodeType == XMLReader::END_ELEMENT) {
      // if we're at the </AuthorList> element then we're done with the article...
      if ($element == 'AuthorList') {
        // build the author list before returning
        $authors = '';
        foreach ($pub['Author List'] as $author) {
          if ($author['valid'] == 'N') {
            // skip non-valid entries.  A non-valid entry should have
            // a corresponding corrected entry so we can saftely skip it.
            continue;
          }
          if ($author['Collective']) {
            $authors .= $author['Collective'] . ', ';
          }
          else {
            $authors .= $author['Surname'] . ' ' . $author['First Initials'] . ', ';
          }
        }
        $authors = substr($authors, 0, -2);
        $pub['Authors'] = $authors;
        return;
      }
      // if we're at the end </Author> element then we're done with the author and we can
      // start a new one.
      if ($element == 'Author') {
        $num_authors++;
      }
    }
    if ($xml->nodeType == XMLReader::ELEMENT) {
      switch ($element) {
        case 'Author':
          $valid = $xml->getAttribute('ValidYN');
          $pub['Author List'][$num_authors]['valid'] = $valid;
          break;
        case 'LastName':
          $xml->read();
          $pub['Author List'][$num_authors]['Surname'] = $xml->value;
          break;
        case 'ForeName':
          $xml->read();
          $pub['Author List'][$num_authors]['Given Name'] = $xml->value;
          break;
        case 'Initials':
          $xml->read();
          $pub['Author List'][$num_authors]['First Initials'] = $xml->value;
          break;
        case 'Suffix':
          $xml->read();
          $pub['Author List'][$num_authors]['Suffix'] = $xml->value;
          break;
        case 'CollectiveName':
          $xml->read();
          $pub['Author List'][$num_authors]['Collective'] = $xml->value;
          break;
        case 'Identifier':
          // according to the specification, this element is not yet used.
          break;
        default:
          break;
      }
    }
  }
}