function tripal_pub_PMID_parse_abstract

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

File

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

Code

function tripal_pub_PMID_parse_abstract($xml, &$pub) {
  $abstract = '';

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

    if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Abstract') {
      // we've reached the </Abstract> element so return
      $pub['Abstract'] = $abstract;
      return;
    }
    // the abstract text can be just a singe paragraph or be broken into multiple
    // abstract texts for structured abstracts.  Here we will just combine then
    // into a single element in the order that they arrive in HTML format
    if ($xml->nodeType == XMLReader::ELEMENT) {
      switch ($element) {
        case 'AbstractText':
          $label = $xml->getAttribute('Label');
          $xml->read();
          if ($label) {
            $part = "<p><b>$label</b></br>" . $xml->value . '</p>';
            $abstract .= $part;
            $pub['Structured Abstract Part'][] = $part;
          }
          else {
            $abstract .= '<p>' . $xml->value . '</p>';
          }
          break;
        case 'CopyrightInformation':
          $xml->read();
          $pub['Copyright'] = $xml->value;
          break;
        default:
          break;
      }
    }
  }
}