Example #1
0
 public function getOriginalXML($bolString = false)
 {
     // convert original (JSON-based) array to xml
     $this->document = Parser::convertToDOMDocument('<original />');
     Parser::addToXML($this->document, 'record', $this->original_array);
     return parent::getOriginalXML($bolString);
 }
Example #2
0
 /**
  * Return values as XML
  * 
  * @param null|array|\ArrayAccess Values to use during rendering
  */
 public function toXML($vars)
 {
     $xml = new \DOMDocument();
     $xml->loadXML("<xerxes />");
     foreach ($vars as $id => $object) {
         Parser::addToXML($xml, $id, $object);
     }
     return $xml;
 }
Example #3
0
 /**
  * Serialize to XML
  * 
  * @return DOMDocument
  */
 public function toXML()
 {
     $objXml = new \DOMDocument();
     $objXml->loadXML("<xerxes_record />");
     $properties = $this->getProperties();
     #### special handling
     // normalized title
     $title_normalized = $this->getTitle(true);
     if ($title_normalized != "") {
         $properties['title_normalized'] = $title_normalized;
     }
     // journal title
     $journal_title = $this->getJournalTitle(true);
     if ($journal_title != "") {
         $properties['journal_title'] = $journal_title;
     }
     // primary author
     $primary_author = $this->getPrimaryAuthor(true);
     if ($primary_author != "") {
         $properties['primary_author'] = $primary_author;
     }
     // full-text indicator
     if ($this->hasFullText()) {
         $properties['full_text_bool'] = 1;
     }
     // authors
     if (count($this->authors) > 0) {
         $objAuthors = $objXml->createElement("authors");
         $x = 1;
         foreach ($this->authors as $objXerxesAuthor) {
             $objAuthor = $objXml->createElement("author");
             $objAuthor->setAttribute("type", $objXerxesAuthor->type);
             if ($objXerxesAuthor->additional == true) {
                 $objAuthor->setAttribute("additional", "true");
             }
             if ($objXerxesAuthor->last_name != "") {
                 $objAuthorLast = $objXml->createElement("aulast", Parser::escapeXml($objXerxesAuthor->last_name));
                 $objAuthor->appendChild($objAuthorLast);
             }
             if ($objXerxesAuthor->first_name != "") {
                 $objAuthorFirst = $objXml->createElement("aufirst", Parser::escapeXml($objXerxesAuthor->first_name));
                 $objAuthor->appendChild($objAuthorFirst);
             }
             if ($objXerxesAuthor->init != "") {
                 $objAuthorInit = $objXml->createElement("auinit", Parser::escapeXml($objXerxesAuthor->init));
                 $objAuthor->appendChild($objAuthorInit);
             }
             if ($objXerxesAuthor->name != "") {
                 $objAuthorCorp = $objXml->createElement("aucorp", Parser::escapeXml($objXerxesAuthor->name));
                 $objAuthor->appendChild($objAuthorCorp);
             }
             if ($objXerxesAuthor->display != "") {
                 $objAuthorDisplay = $objXml->createElement("display", Parser::escapeXml($objXerxesAuthor->display));
                 $objAuthor->appendChild($objAuthorDisplay);
             }
             $objAuthor->setAttribute("rank", $x);
             if ($x == 1 && $this->editor == true) {
                 $objAuthor->setAttribute("editor", "true");
             }
             $objAuthors->appendChild($objAuthor);
             $x++;
         }
         $objXml->documentElement->appendChild($objAuthors);
     }
     // standard numbers
     if (count($this->issns) > 0 || count($this->isbns) > 0 || $this->govdoc_number != "" || $this->gpo_number != "" || $this->oclc_number != "") {
         $objStandard = $objXml->createElement("standard_numbers");
         if (count($this->issns) > 0) {
             foreach ($this->issns as $strIssn) {
                 $objIssn = $objXml->createElement("issn", Parser::escapeXml($strIssn));
                 $objStandard->appendChild($objIssn);
             }
         }
         if (count($this->isbns) > 0) {
             foreach ($this->isbns as $strIsbn) {
                 $objIssn = $objXml->createElement("isbn", Parser::escapeXml($strIsbn));
                 $objStandard->appendChild($objIssn);
             }
         }
         if ($this->govdoc_number != "") {
             $objGovDoc = $objXml->createElement("gpo", Parser::escapeXml($this->govdoc_number));
             $objStandard->appendChild($objGovDoc);
         }
         if ($this->gpo_number != "") {
             $objGPO = $objXml->createElement("govdoc", Parser::escapeXml($this->gpo_number));
             $objStandard->appendChild($objGPO);
         }
         if ($this->oclc_number != "") {
             $objOCLC = $objXml->createElement("oclc", Parser::escapeXml($this->oclc_number));
             $objStandard->appendChild($objOCLC);
         }
         $objXml->documentElement->appendChild($objStandard);
     }
     ## basic elements
     foreach ($properties as $key => $value) {
         // these are utility variables
         if ($key == "utility" || in_array($key, $this->utility)) {
             continue;
         }
         // these we handled these above
         if ($key == "authors" || $key == "isbns" || $key == "issns" || $key == "govdoc_number" || $key == "gpo_number" || $key == "oclc_number") {
             continue;
         }
         // otherwise, create a new node
         Parser::addToXML($objXml, $key, $value);
     }
     return $objXml;
 }
Example #4
0
 /**
  * Return values as XML
  * 
  * @param null|array|\ArrayAccess Values to use during rendering
  */
 public function toXML($vars)
 {
     $xml = Parser::convertToDOMDocument('<xerxes />');
     foreach ($vars as $id => $object) {
         Parser::addToXML($xml, $id, $object);
     }
     return $xml;
 }