function iso2709toXML_notice($contents, $format = "unimarc") { global $output_params, $charset; $n_notices = 0; $n_valid = 0; $n_invalid = 0; $this->n_traitees = 0; $this->n_valid = 0; $this->n_invalid = 0; $this->error_msg = array(); $this->warning_msg = array(); $this->notices_xml_ = array(); while ($contents != "") { $e_notice = strpos($contents, chr(0x1d)); $notice = substr($contents, 0, $e_notice + 1); $contents = substr($contents, $e_notice + 1); $n = new iso2709_record($notice, AUTO_UPDATE, $format); if ($n->is_utf8) { $this->is_utf8 = true; } else { if ($output_params['CHARSET'] == "utf-8") { $n->inner_guide['pos9'] = "a"; } } if ($n->valid()) { //Récupération des infos //Taille code sous-champ $sl = $n->inner_guide["sl"]; //Taille des inticateurs $il = $n->inner_guide["il"]; $data .= " <notice>\n"; //Etat de la notice $values = array("rs", "dt", "bl", "hl", "el", "ru"); for ($i = 0; $i < count($values); $i++) { $v = $n->inner_guide[$values[$i]]; if (ord($v) == 32) { $v = "*"; } $data .= " <" . $values[$i] . ">" . $v . "</" . $values[$i] . ">\n"; } for ($i = 0; $i < count($n->inner_data); $i++) { $data .= " <f c=\"" . $n->inner_data[$i]["label"] . "\""; $content = substr($n->inner_data[$i]["content"], 0, strlen($n->inner_data[$i]["content"]) - 1); $sub_fields = explode(chr(31), $content); if (count($sub_fields) == 1) { $data .= ">" . htmlspecialchars($this->is_utf8 ? $sub_fields[0] : $n->ISO_decode($sub_fields[0]), ENT_QUOTES, $charset) . "</f>\n"; } else { if (strlen($sub_fields[0]) > 2) { $sub_fields[0] = substr($sub_fields[0], strlen($sub_fields[0]) - 2); } $data .= " ind=\"" . $sub_fields[0] . "\">\n"; for ($j = 1; $j < count($sub_fields); $j++) { $data .= " <s c=\"" . substr($sub_fields[$j], 0, 1) . "\">" . htmlspecialchars($this->is_utf8 ? substr($sub_fields[$j], 1) : $n->ISO_decode(substr($sub_fields[$j], 1)), ENT_QUOTES, $charset) . "</s>\n"; } $data .= " </f>\n"; } } $data .= " </notice>\n"; $this->notices_xml_[] = $data; $n_valid++; } else { $this->error_msg[] = @implode(" / ", $n->errors); $n_invalid++; } $n_notices++; } $this->n_traitees = $n_notices; $this->n_valid = $n_valid; $this->n_invalid = $n_invalid; return $n_notices; }