preprocessInfo.php 1.1 KB
<?php
/**
*
*/
	$id = $argv[1];
	$NEWMETA = getenv('NEWMETA');
			
	$infoXml = new DomDocument("1.0");	 	
	$infoXml->load($NEWMETA."final/$id.xml");
		
	$infoBlock =  $infoXml->getElementsByTagName('info')->item(0);
	$components = $infoBlock->getElementsByTagName('components')->item(0);
	
	if ($components->nodeValue != "") {
	
		echo "COMP ".$components->nodeValue.PHP_EOL;
		$comps = explode(',',$components->nodeValue);
		
		if (count($comps) == 3) { 
			$argsXml = new DomDocument("1.0");
			$root = $argsXml->createElement('paraminfo');
			$root->setAttribute('xml:id',$id);
			$dim = $argsXml->createElement('dimensions');
			$dim->setAttribute('dim_1',3);
			$dim->setAttribute('dim_2',1);
			$root->appendChild($dim);
			$cmps = $argsXml->createElement('components');
			$root->appendChild($cmps);
			for ($i = 0; $i < count($comps); $i++) {			
				$cmp = $argsXml->createElement('component');
				$cmp->setAttribute('index_1',$i);
				$cmp->setAttribute('name',$comps[$i]);
				$cmps->appendChild($cmp);
			}	
			
			$argsXml->appendChild($root);
			$argsXml->save($NEWMETA."ParamInfo/info_$id.xml");
		}
	}   
?>