SimpleXMLElement XML отображается в виде обычного текста после обновления CI3 до CI4.Php

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 SimpleXMLElement XML отображается в виде обычного текста после обновления CI3 до CI4.

Сообщение Anonymous »

Я обновляю страницу с CI3 до CI4. На странице есть кнопка для открытия новой вкладки, на которой отображаются данные XML. По какой-то причине версия CI4 показывает XML как обычный текст. Я скопировал исходный код каждой XML-страницы и сравнил их, и единственная разница, которую я вижу, — это URL-адреса (одна страница указывает на производство, а другая — на разработку). Страница CI4, похоже, в исходном коде отформатирована как XML. Почему страница CI4 не отображается в формате XML?
Ссылка на XML CI3: https://www.uvm.edu/femc/data/archive/p ... ear-brook- Watershed-Maine/dataset/vegetation-size-categories-corresponding-plot-size/eml_xmlview
Ссылка на CI4 «XML»: https://dev.vmc.w3.uvm.edu/xana/CI4/dat ... ml_xmlview
Вот код, используемый для создания страницы CI4:
в контроллере:
public function eml_xmlview($projecttitle = NULL, $datasettitle = NULL) {

//Get project and dataset ids from web title, if no match show 404
$pid=$this->common->get_itemid('project', $projecttitle);
$did=$this->common->get_itemid('dataset', $datasettitle);
if($pid==-1){
show_404();
}

$published=($this->common->check_publish('tblProject', 'fldPublish','pkProjectID',$pid) AND $this->common->check_publish('tblDataset', 'fldPublishMetadata','pkDatasetID',$did));
//Check if the person coming to the management section is allowed to manage this particular project
$canmanage=$this->dataset_model->can_manage_dataset($pid,$did,'permission_project_datasets'); //Check whether person logged in can view unpublished data
//Find out if this project should be hidden - basically, check if the project is published, or the person is admin, or the person can manage it
$show=($published OR $canmanage);
if(!$show){
show_404();
}

$dataset = $this->dataset_model->get_dataset($pid, $did);
$project = (ENVIRONMENT=="production") ? $this->project_model->get_projectverbose($pid) : $this->project_model->get_projectverbose($pid, FALSE);
$fields = $this->dataset_model->get_fields($did);
$version = 1; //Placeholder in case we want to add version to package ids later
if (!empty($project)){
$project=array_pop($project);
}

$emlstart = addChild('publisher');
$mtp = $pbl->addChild('metadataProvider');
$mtp->addChild('organizationName','Forest Ecosystem Monitoring Cooperative');
$mtp->addChild('phone','(802) 656-0683');
$mtp->addChild('electronicMailAddress','femc@uvm.edu');
$mtp->addChild('onlineUrl','www.uvm.edu/femc');
$adr = $mtp->addChild('address');
$adr->addChild('deliveryPoint','705 Spear Street');
$adr->addChild('city','South Burlington');
$adr->addChild('administrativeArea','Vermont');
$adr->addChild('postalCode','05403');
$adr->addChild('country','United States of America');
//Add project organizations
$orgsQry = $this->db->query("SELECT * FROM (SELECT * FROM tblOrganization
JOIN tblProjectOrganization on tblOrganization.pkOrganizationID = tblProjectOrganization.fkOrganizationID
WHERE fkProjectID = $pid) t
GROUP BY t.fkOrganizationID, t.enuOrganizationRole
ORDER BY enuOrganizationRole, fldStartDate;");
$orgrolesAr = array();
foreach($orgsQry->getResult() as $row) {
$orgrolesAr["$row->enuOrganizationRole"][] = "$row->fldName1 $row->fldName2";
}

foreach($orgrolesAr as $role=>$orgAr) {
$ap=$emldata->addChild('associatedParty');

foreach($orgAr as $index=>$orgName) {
$ap->addChild('organizationName',$this->common->sanitizeForXML($orgName));
}
$ap->addChild('role',$role);
}

//Project-level
if($project['enuProjectType'] == 'research'){
$prj = $emldata->addChild('researchProject');
}
else{
$prj = $emldata->addChild('project');
}
$prj->addChild('title', $this->common->sanitizeForXML($project['fldProjectName']));
$prj->addChild('abstract')->addChild('para', $this->common->sanitizeForXML($project['fldProjectDescription']));
$prj->addChild('shortName',$this->common->sanitizeForXML($project['fldProjectName']));
$prs = $prj->addChild('personnel');
if(!empty($project['people'])){
foreach($project['people'] as $person){
if($person['enuRole']=='principal-investigator'){
$prn = $prs->addChild('principalInvestigator');
}
else{
$prn = $prs->addChild('contentProvider');
}
$prn->addChild('surName',$this->common->sanitizeForXML($person['fldLastName']));
$prn->addChild('givenName',$this->common->sanitizeForXML($person['fldFirstName']));
}
}
if(!empty($project['tags'])){
$kws = $prj->addChild('keywordSet');
foreach($project['tags'] as $tag){
$kws->addChild('keyword',$this->common->sanitizeForXML($tag['fldTag']));
}
}

//Dataset-level
$dataTable = $emldata->addChild('dataTable');
$dataTable->addChild('title', $this->common->sanitizeForXML($dataset['fldName']));
$cvr = $dataTable->addChild('coverage');
$cvr->addAttribute('scope','document');
$tmp = $cvr->addChild('temporalCoverage');
$tmp->addAttribute('scope','document');
$rng = $tmp->addChild('rangeOfDates');
if($dataset['fldStartDate'] && $dataset['fldStartDate'] != '0000-00-00'){
$rng->addChild('beginDate')->addChild('calendarDate',$dataset['fldStartDate']);
}
if($dataset['fldEndDate'] && $dataset['fldEndDate'] != '0000-00-00'){
$rng->addChild('endDate')->addChild('calendarDate',$dataset['fldEndDate']);
}
$dataTable->addChild('description',$this->common->sanitizeForXML($dataset['fldDescription']));
$dataTable->addChild('purpose',$this->common->sanitizeForXML($dataset['fldPurpose']));
$dataTable->addChild('shortName',$this->common->sanitizeForXML($dataset['fldDatabaseTableName']));
$phy = $dataTable->addChild('physical');
$phy->addChild('objectName','VMC.' . $pid . '.' . $did);
$dfo = $phy->addChild('dataFormat');
$dfo->addChild('formatName','mySQL');
$phy->addChild('citation',$this->common->sanitizeForXML($dataset['fldDatasetCitation']));
$phy->addChild('distibution')->addChild('online')->addChild('url', site_url('data/archive/project/'.$this->common->sanitizeForXML($project['fldWebTitle']).'/dataset/'.$this->common->sanitizeForXML($dataset['fldWebTitle'])));
$atl = $dataTable->addChild('attributeList');
foreach($fields as $field){
$att = $atl->addChild('attribute');
$att->addChild('attributeName',$this->common->sanitizeForXML($field['fldFieldName']));
if($field['fldCaption']){
$att->addChild('attributeLabel',$this->common->sanitizeForXML($field['fldCaption']));
}
if($field['fldFieldDescription']){
$att->addChild('attributeDefinition',$this->common->sanitizeForXML($field['fldFieldDescription']));
}
if($field['enuDataType']){
$att->addChild('storageType',$this->common->sanitizeForXML($field['enuDataType']));
}
if($field['enuMeasurementType']){
$mst = $att->addChild('measurementType');
$typ = $mst->addChild(strtolower($this->common->sanitizeForXML($field['enuMeasurementType'])));
if($field['enuUnit']){
$typ->addChild('unit')->addChild('standardUnit',$this->common->sanitizeForXML($field['enuUnit']));
}
if($field['fldPrecision']){
$typ->addChild('precision',$this->common->sanitizeForXML($field['fldPrecision']));
}
if($field['enuFormatString']){
$typ->addChild('formatString',$this->common->sanitizeForXML($field['enuFormatString']));
}
if($field['enuNumberType']){
$typ->addChild('numericDomain')->addChild('numberType',$this->common->sanitizeForXML($field['enuNumberType']));
}
if($field['fldMinimum'] || $field['fldMaximum']){
$bdg = $typ->addChild('BoundsGroup');
$bds = $bdg->addChild('bounds');
$bds->addChild('minimum',$field['fldMinimum']);
$bds->addChild('maximum',$field['fldMaximum']);
}
}
if($field['fldEnumList'] && $field['fkLookupID']){
$list = $this->dataset_model->get_list($field['fkLookupID']);
if(!empty($list)){
$grouplist=array();
list($grouplist['list'],$grouplist['listtype'],$grouplist['listname'])=$list;
}
switch ($grouplist['listtype']){
case "custom":
$enu = $att->addChild('enumeratedDomain');
foreach($grouplist['list'] as $pairing){
$cdd = $enu->addChild('codeDefinition');
$cdd->addChild('code', $this->common->sanitizeForXML($pairing['fldItem']));
$cdd->addChild('definition', $this->common->sanitizeForXML($pairing['fldDescription']));
}
break;
case "species":
$enu = $att->addChild('enumeratedDomain');
$speciesCoverage = $dataTable->addChild('coverage');
$tmp = $speciesCoverage->addChild('taxonomicCoverage');
foreach($grouplist['list'] as $pairing){
$cdd = $enu->addChild('codeDefinition');
$cdd->addChild('code', $this->common->sanitizeForXML($pairing['fldOriginalCode']));
$cdd->addChild('definition', $this->common->sanitizeForXML($pairing['enuTaxonomicSystem'].' #'.$pairing['fldTaxonomicID'].', '.$pairing['fldCommonName'].' ('.$pairing['fldGenus'].' '.$pairing['fldSpecies'].')'));
}

break;
case "location":
$enu = $att->addChild('enumeratedDomain');
foreach($grouplist['list'] as $pairing){
$cdd = $enu->addChild('codeDefinition');
$cdd->addChild('code', $this->common->sanitizeForXML($pairing['fldOriginalCode']));
if (!empty($pairing['descLocationType'])){
$cdd->addChild('definition', $this->common->sanitizeForXML($pairing['descLocationType'].' '.$pairing['fldDescription']));
}else{
$cdd->addChild('definition', $this->common->sanitizeForXML($pairing['fldDescription']));
}
}
break;
default:
break;

}
}
}
//$dataTable->addChild('license',$dataset['enuDataLicense']);

$sxe->saveXML();
$data['sxe'] = $sxe->asXML();
$data['dump']=false;
echo view('project/dataset/eml_xmlview', $data);
}

в представлении:



Подробнее здесь: https://stackoverflow.com/questions/793 ... i4-upgrade
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»