=') && extension_loaded('xsl')) { if (substr(phpversion(), 0, 1) == "5") @ini_set("zend.ze1_compatibility_mode", "0"); require_once($include_path.'/xslt-php4-to-php5.inc.php'); } //Bibliothèque des transformations par défaut require_once ("$base_path/admin/convert/xml_unimarc.class.php"); //Conversion par une feuille de style XSLT function perform_xslt($xml, $s, $islast, $isfirst, $param_path) { global $base_path, $charset; $transform="$base_path/admin/convert/imports/".$param_path."/".$s['XSLFILE'][0]['value']; //Si c'est la première transformation, on rajoute les entêtes if ($isfirst) { if($s['ENCODING']){ $xml1 = "\n<".$s['ROOTELEMENT'][0]["value"]; }else{ $xml1 = "\n<".$s['ROOTELEMENT'][0]["value"]; } if ($s["NAMESPACE"]) { $xml1.=" xmlns:".$s["NAMESPACE"][0]["ID"]."='".$s["NAMESPACE"][0]["value"]."' "; } $xml1.=">\n".$xml."\n"; $xml=$xml1; } $f = fopen($transform, "r"); $xsl = fread($f, filesize($transform)); fclose($f); //Création du processeur $xh = xslt_create(); //Encodage = $charset if (defined("ICONV_IMPL")) { xslt_set_encoding($xh, "$charset"); } // Traite le document if ($result = @xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array("/_xml" => $xml, "/_xsl" => $xsl))) { $r['VALID']=true; $r['DATA']=$result; $r['ERROR']=""; //Si c'est la dernière transformation, on supprime les entêtes et l'élément root if ($islast) { $p = preg_match("/<".$s['TNOTICEELEMENT'][0]['value']."(?:\ [^>]*|)>/", $r["DATA"], $m, PREG_OFFSET_CAPTURE); if ($p) { $r['DATA'] = " ".substr($r['DATA'], $m[0][1]); } $p1 = 0; $p = 0; while ($p!==false) { $p1 = $p; $p = @strpos($r['DATA'], "",$p1+strlen("")); } if (($p1 !== false)&&($p1!=0)) { $r['DATA'] = substr($r['DATA'], 0, $p1+strlen($s['TNOTICEELEMENT'][0]['value'])+3)."\n"; } } } else { $r['VALID']=false; $r['DATA']=""; $r['ERROR']="Sorry, notice could not be transformed by $transform the reason is that ".xslt_error($xh)." and the error code is ".xslt_errno($xh); } xslt_free($xh); return $r; } //Conversion XML en iso2709 function toiso($notice, $s, $islast, $isfirst, $param_path) { $x2i = new xml_unimarc(); $x2i -> XMLtoiso2709_notice($notice,$s['ENCODING']); if($x2i->warning_msg[0]){ $r['WARNING']=$x2i->warning_msg[0]; } if ($x2i->n_valid==0) { $r['VALID']=false; $r['DATA']=""; $r['ERROR']=$x2i->error_msg[0]; } else { $r['VALID']=true; $r['DATA']=$x2i->notices_[0]; $r['ERROR']=""; } return $r; } //Consersion iso2709 en XML function isotoxml($notice, $s, $islast, $isfirst, $param_path) { global $charset; global $output_params; $i2x = new xml_unimarc(); $i2x->iso2709toXML_notice($notice,$s['FORMAT']); if ($i2x->n_valid == 0) { $r['VALID']=false; $r['DATA']=""; $r['ERROR']=$i2x->error_msg[0]; } else { $r['VALID']=true; $r['DATA']=$i2x->notices_xml_[0]; $r['ERROR']=""; //Si ce n'est pas la dernière transformation, on rajoute des tags root et l'entête if (!$islast) { $r['DATA'] = "<".$s['TROOTELEMENT'][0]['value'].">\n".$r['DATA']; $r['DATA'].= ""; $r['DATA'] = "is_utf8?"utf-8":$charset)."\" ?>\n".$r['DATA']; } } return $r; } //Conversion texte en XML function texttoxml($notice, $s, $islast, $isfirst, $param_path) { global $cols, $charset; eval("\$spt=\"".$s["SEPARATOR"][0]["value"]."\";"); $fields=explode($spt,$notice); //Recherche du type doc if ($s["COLS"][0]["DT"]) { if ($s["COLS"][0]["DT"][0]["CORRESP"][0]) { $corresp=$s["COLS"][0]["DT"][0]["CORRESP"][0]; $f_id=$fields[($corresp["ID"]-1)]; if ($s["DELIMITEDBY"][0]["value"]) { $f_id=trim($f_id,$s["DELIMITEDBY"][0]["value"]); } for ($i=0; $i"; } else { $f["value"]=$fields[$i]; } $param["f"][]=$f; }*/ $r['DATA']=@array_to_xml($param,"notice"); if ($r['DATA']) { //Si ce n'est pas la dernière transformation, on rajoute des tags root et l'entête if (!$islast) { $r['DATA'] = "<".$s['TROOTELEMENT'][0]['value'].">\n".$r['DATA']; $r['DATA'].= ""; $r['DATA'] = "\n".$r['DATA']; } $r['VALID']=true; $r['ERROR']=""; } else { $r['VALID']=false; $r['ERROR']="Can't convert to XML line ".$notice; } return $r; }