Skip to content
Snippets Groups Projects
Commit ccbae7c4 authored by Laurent's avatar Laurent
Browse files

hotline#61844 perf improvements

parent 0f15e3f1
Branches
Tags
3 merge requests!2334Master,!2241Stable,!2235Hotline#61844 encore des problemes sur la vod
Pipeline #1874 failed with stage
in 9 minutes and 25 seconds
......@@ -61,8 +61,7 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
* @return Class_WebService_SIGB_*_PatronInfoReader
*/
public function parseXML($xml) {
$this->_xml_parser = Class_WebService_FasterXMLParser::newInstance()
->setElementHandler($this);
$this->_xml_parser = $this->_newXMLParser()->setElementHandler($this);
$this->_xml_parser->parse($xml);
......@@ -70,6 +69,11 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
}
protected function _newXMLParser() {
return Class_WebService_FasterXMLParser::newInstance();
}
/**
* @param string $data
*/
......
......@@ -38,6 +38,11 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIG
}
protected function _newXMLParser() {
return Class_WebService_XMLParser::newInstance();
}
/**
* @param string $data
*/
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_SIGB_Nanook_XMLParser extends Class_WebService_FasterXMLParser {
/**
* @param string $xml
* @return string
*/
protected function stripInvalidXml($xml) {
if (empty($xml)) {
return '';
}
$ret = "";
$length = strlen($xml);
for ($i=0; $i < $length; $i++) {
$current = ord($xml{$i});
// http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
if (($current == 0x9) ||
($current == 0xA) ||
($current == 0xD) ||
(($current >= 0x20) && ($current <= 0xD7FF)) ||
(($current >= 0xE000) && ($current <= 0xFFFD)) ||
(($current >= 0x10000) && ($current <= 0x10FFFF)))
{
$ret .= chr($current);
} else {
$ret .= " ";
}
}
return $ret;
}
/**
* @param string $xml
* @return Class_WebService_XMLParser
*/
public function parse($xml) {
$xml = preg_replace_callback("/(&#[0-9]+;)/", function($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $xml);
$xml = $this->stripInvalidXml($xml);
return parent::parse($xml);
}
}
\ No newline at end of file
......@@ -39,44 +39,12 @@ class Class_WebService_XMLParser {
$this->remove_namespace=false;
}
/**
* @param string $xml
* @return string
*/
protected function stripInvalidXml($xml) {
if (empty($xml)) {
return '';
}
$ret = "";
$length = strlen($xml);
for ($i=0; $i < $length; $i++) {
$current = ord($xml{$i});
// http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
if (($current == 0x9) ||
($current == 0xA) ||
($current == 0xD) ||
(($current >= 0x20) && ($current <= 0xD7FF)) ||
(($current >= 0xE000) && ($current <= 0xFFFD)) ||
(($current >= 0x10000) && ($current <= 0x10FFFF)))
{
$ret .= chr($current);
} else {
$ret .= " ";
}
}
return $ret;
}
/**
* @param string $xml
* @return Class_WebService_XMLParser
*/
public function parse($xml) {
$xml = preg_replace_callback("/(&#[0-9]+;)/", function($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $xml);
$xml = $this->stripInvalidXml($xml);
$this->_parsed_xml = $xml;
$this->_parents = array() ;
$parser = $this->_createParser() ;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment