Changing the first lines of the definition of function
generateModel in syntax/RdfParser.php is 100% downward
compatible but allows to print status/progress
information on the command line when loading larger models:
function & generateModel($base,$rdfBaseURI = false,
$model = false,$blockSize=512,$secondsBetweenStatus=0) {
// Check if $base is a URI or filename or a string
containing RDF code.
if (substr(ltrim($base),0 ,1) != '<') {
// $base is URL or filename
$this->model = $model?$model:new MemModel($base);
$input = fopen($base,'r') or die("RDF Parser: Could
not open File: $base. Stopped parsing.");
$this->rdf_parser_create( NULL );
$this->rdf_set_base($base);
$done=false;
$start=time();
$size=filesize($base);
while(!$done)
{
$buf = fread( $input, $blockSize );
if($secondsBetweenStatus) {
$counter++;
if(time()>$lasttime+$secondsBetweenStatus) {
$bps=time()-$start?($counter*$blockSize)/(time()-$start):1;
$secondsToGo=($size-$counter*$blockSize)/$bps;
printf("%6d kB read at %6d B/s ~ %2d:%2d:%2d
s to
go\n",$counter*$blockSize/1024,$bps,$secondsToGo/3600,$secondsToGo%3600/60,$secondsToGo%60);
$lasttime=time();
}
}
$done = feof($input);
if ( ! $this->rdf_parse( $buf, feof($input) ) )
{
$err_code = xml_get_error_code(
$this->rdf_get_xml_parser());
$line =
xml_get_current_line_number($this->rdf_get_xml_parser() );
$errmsg = RDFAPI_ERROR . '(class: parser; method:
generateModel): XML-parser-error ' . $err_code .' in
Line ' . $line .' of input document.';
trigger_error($errmsg, E_USER_ERROR);
}
}