function parse($path, $data = '')
{
$this->state = 0;
/* reader */
if (!$this->v('reader')) {
ARC2::inc('Reader');
$this->reader =& new ARC2_Reader($this->a, $this);
}
$this->reader->setAcceptHeader('Accept: sparql-results+xml; q=0.9, */*; q=0.1');
$this->reader->activate($path, $data);
$this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
/* xml parser */
$this->initXMLParser();
/* parse */
$first = true;
while ($d = $this->reader->readStream()) {
if (!xml_parse($this->xml_parser, $d, false)) {
$error_str = xml_error_string(xml_get_error_code($this->xml_parser));
$line = xml_get_current_line_number($this->xml_parser);
$this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')';
return $this->addError($this->tmp_error);
}
}
$this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING);
xml_parser_free($this->xml_parser);
$this->reader->closeStream();
return $this->done();
}