/** * Parse a record's contents into an object * @param $contents string * @return object */ function &parseContents(&$contents) { $xmlParser = new XMLParser(); $result =& $xmlParser->parseText($contents); $returner = array(); $returner =& $this->handleRootNode($result); $result->destroy(); $xmlParser->destroy(); return $returner; }
/** * Parse a record's contents into an object * @param $contents string * @return object */ function &parseContents(&$contents) { $xmlParser = new XMLParser(); $result =& $xmlParser->parseText($contents); $returner = array(); $modsNode =& $result->getChildByName(array('oai_mods:mods', 'mods:mods', 'mods')); if (!isset($modsNode)) { $returner = null; return $returner; } $returner =& $this->handleRootNode($modsNode); $result->destroy(); $xmlParser->destroy(); return $returner; }
/** * SUSHI report * @param $useLegacyStats boolean */ function _sushiXML($useLegacyStats) { $templateManager =& TemplateManager::getManager(); $SOAPRequest = file_get_contents('php://input'); // crude handling of namespaces in the input // FIXME: only the last prefix in the input will be used for each namespace $soapEnvPrefix = ''; $sushiPrefix = ''; $counterPrefix = ''; $re = '/xmlns:([^=]+)="([^"]+)"/'; preg_match_all($re, $SOAPRequest, $mat, PREG_SET_ORDER); foreach ($mat as $xmlns) { $modURI = $xmlns[2]; if (strrpos($modURI, '/') + 1 == strlen($modURI)) { $modURI = substr($modURI, 0, -1); } switch ($modURI) { case 'http://schemas.xmlsoap.org/soap/envelope': $soapEnvPrefix = $xmlns[1]; break; case 'http://www.niso.org/schemas/sushi': $sushiPrefix = $xmlns[1]; break; case 'http://www.niso.org/schemas/sushi/counter': $counterPrefix = $xmlns[1]; break; } } if (strlen($soapEnvPrefix) > 0) { $soapEnvPrefix .= ':'; } if (strlen($sushiPrefix) > 0) { $sushiPrefix .= ':'; } if (strlen($counterPrefix) > 0) { $counterPrefix .= ':'; } $parser = new XMLParser(); $tree = $parser->parseText($SOAPRequest); $parser->destroy(); // is this necessary? if (!$tree) { $templateManager->assign('Faultcode', 'Client'); $templateManager->assign('Faultstring', 'The parser was unable to parse the input.'); header("HTTP/1.0 500 Internal Server Error"); $templateManager->display($this->getTemplatePath() . 'soaperror.tpl', 'text/xml'); } else { $reportRequestNode = $tree->getChildByName($soapEnvPrefix . 'Body')->getChildByName($counterPrefix . 'ReportRequest'); $requestorID = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'ID')->getValue(); $requestorName = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'Name')->getValue(); $requestorEmail = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'Email')->getValue(); $customerReferenceID = $reportRequestNode->getChildByName($sushiPrefix . 'CustomerReference')->getChildByName($sushiPrefix . 'ID')->getValue(); $reportName = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getAttribute('Name'); $reportRelease = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getAttribute('Release'); $usageDateRange = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getChildByName($sushiPrefix . 'Filters')->getChildByName($sushiPrefix . 'UsageDateRange'); $usageDateBegin = $usageDateRange->getChildByName($sushiPrefix . 'Begin')->getValue(); $usageDateEnd = $usageDateRange->getChildByName($sushiPrefix . 'End')->getValue(); $this->_assignTemplateCounterXML($templateManager, $usageDateBegin, $usageDateEnd, $useLegacyStats); $templateManager->assign('requestorID', $requestorID); $templateManager->assign('requestorName', $requestorName); $templateManager->assign('requestorEmail', $requestorEmail); $templateManager->assign('customerReferenceID', $customerReferenceID); $templateManager->assign('reportName', $reportName); $templateManager->assign('reportRelease', $reportRelease); $templateManager->assign('usageDateBegin', $usageDateBegin); $templateManager->assign('usageDateEnd', $usageDateEnd); $templateManager->assign('templatePath', $this->getTemplatePath()); $templateManager->display($this->getTemplatePath() . 'sushixml.tpl', 'text/xml'); } }
/** * Parse a record's contents into an object * @param $contents string * @return object */ function &parseContents(&$contents) { $xmlParser = new XMLParser(); $result =& $xmlParser->parseText($contents); $returner = array(); foreach ($result->getChildren() as $child) { $name = $child->getName(); $value = $child->getValue(); if (String::substr($name, 0, 6) == 'etdms:') { $name = String::substr($name, 3); } $returner[$name][] = $value; } $result->destroy(); $xmlParser->destroy(); unset($result, $xmlParser); return $returner; }
/** * Parse a record's contents into an object * @param $contents string * @return object */ function &parseContents(&$contents) { $xmlParser = new XMLParser(); $result =& $xmlParser->parseText($contents); $returner = array(); foreach ($result->getChildren() as $child) { $name = $child->getName(); switch ($child->getName()) { case 'varfield': $id = $child->getAttribute('id'); $i1 = $child->getAttribute('i1'); $i2 = $child->getAttribute('i2'); foreach ($child->getChildren() as $subfield) { if ($subfield->getName() != 'subfield') { continue; } $value = $subfield->getValue(); if (empty($value)) { continue; } $label = $subfield->getAttribute('label'); $returner[$id][$i1][$i2][$label][] = $value; } break; case 'datafield': $id = $child->getAttribute('tag'); $i1 = $child->getAttribute('ind1'); $i2 = $child->getAttribute('ind2'); foreach ($child->getChildren() as $subfield) { if ($subfield->getName() != 'subfield') { continue; } $value = $subfield->getValue(); if (empty($value)) { continue; } $label = $subfield->getAttribute('code'); $returner[$id][$i1][$i2][$label][] = $value; } break; case 'controlfield': break; } } $result->destroy(); $xmlParser->destroy(); unset($result, $xmlParser); return $returner; }