private function _processDomainNode($domainNode) { if ($this->_xml) { $guid = (string) $domainNode['guid']; } $s = new SemDomTransItemModel($this->_projectModel); $s->readByProperty("xmlGuid", $guid); $abbreviation = $this->_getPathVal($domainNode->xpath("Abbreviation/AUni[@ws='en']")); // if XML file does not have to be recreated, just assign to appropriate fields // if XML has to be recreated, then add appropriate children nodes to XML file if (!$this->_recreateXMLFile) { $name = $domainNode->xpath("Name/AUni[@ws='{$this->_lang}']")[0]; $description = $domainNode->xpath("Description/AStr[@ws='{$this->_lang}']")[0]->xpath("Run[@ws='{$this->_lang}']")[0]; $name[0] = SemDomTransStatus::isApproved($s->name->status) ? $s->name->translation : ''; $description[0] = SemDomTransStatus::isApproved($s->description->status) ? $s->description->translation : ''; } else { $name = $domainNode->Name; $nameChild = clone $domainNode->Name->AUni; $nameChild["ws"] = $this->_lang; $nameChild[0] = SemDomTransStatus::isApproved($s->name->status) ? $s->name->translation : ''; SemDomXMLExporter::_addChild($name, $nameChild); $description = $domainNode->Description; $descriptionChild = clone $domainNode->Description->AStr; $descriptionChild["ws"] = $this->_lang; $descriptionChild->Run["ws"] = $this->_lang; $descriptionChild->Run[0] = SemDomTransStatus::isApproved($s->description->status) ? $s->description->translation : ''; SemDomXMLExporter::_addChild($description, $descriptionChild); } $questions = new ArrayOf(function ($data) { return new SemDomTransQuestion(); }); $searchKeys = new ArrayOf(function ($data) { return new SemDomTransTranslatedForm(); }); if (property_exists($domainNode, 'Questions')) { $questionsXML = $domainNode->Questions; // parse nested questions $index = 0; foreach ($questionsXML->children() as $questionXML) { // if XML file does not have to be recreated, just assign to appropriate fields // if XML has to be recreated, then add appropriate children nodes to XML file if (!$this->_recreateXMLFile) { $question = $this->_getNodeOrNull($questionXML->xpath("Question/AUni[@ws='{$this->_lang}']")); $terms = $this->_getNodeOrNull($questionXML->xpath("ExampleWords/AUni[@ws='{$this->_lang}']")); if ($question != null && SemDomTransStatus::isApproved($s->questions[$index]->question->status)) { $question[0] = $s->questions[$index]->question->translation; } else { $question[0] = ''; } if ($terms != null && SemDomTransStatus::isApproved($s->questions[$index]->question->status)) { $terms[0] = $s->questions[$index]->terms->translation; } } else { $question = $questionXML->Question; $terms = $questionXML->ExampleWords; if (!empty($question)) { $questionChild = clone $question->AUni; $questionChild["ws"] = $this->_lang; if (SemDomTransStatus::isApproved($s->questions[$index]->question->status)) { $questionChild[0] = $s->questions[$index]->question->translation; } else { $questionsChild[0] = ''; } SemDomXMLExporter::_addChild($question, $questionChild); } if (!empty($terms)) { $termsChild = clone $terms->AUni; $termsChild["ws"] = $this->_lang; if (SemDomTransStatus::isApproved($s->questions[$index]->terms->status)) { $termsChild[0] = $s->questions[$index]->question->translation; } else { $termsChild[0] = ''; } $termsChild[0] = $s->questions[$index]->terms->translation; SemDomXMLExporter::_addChild($terms, $termsChild); } } $index++; } } //print "Processed $abbreviation \n"; // recurse on sub-domains if (property_exists($domainNode, 'SubPossibilities')) { foreach ($domainNode->SubPossibilities->children() as $subDomainNode) { $this->_processDomainNode($subDomainNode); } } }