function parse()
{
while (($data = $this->reader->read()) !== -1) {
if (!xml_parse($this->parser, $data, $this->reader->eof())) {
$error = xml_error_string(xml_get_error_code($this->parser));
$e = new ExpatParseException($error, $this->getLocation());
xml_parser_free($this->parser);
throw $e;
}
}
xml_parser_free($this->parser);
return 1;
}
/** * Transform the data dump input file into SQL and writes it to the output stream. * * @param PhingFile $xmlFile * @param Writer $out */ public function transform(PhingFile $xmlFile, Writer $out) { $this->sqlWriter = $out; // Reset some vars just in case this is being run multiple times. $this->currTableName = $this->currBuilder = null; $this->builderClazz = $this->generatorConfig->getBuilderClassname('datasql'); try { $fr = new FileReader($xmlFile); } catch (Exception $e) { throw new BuildException("XML File not found: " . $xmlFile->getAbsolutePath()); } $br = new BufferedReader($fr); $this->parser = new ExpatParser($br); $this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0); $this->parser->setHandler($this); try { $this->parser->parse(); } catch (Exception $e) { print $e->getMessage() . "\n"; $br->close(); } $br->close(); }