parse() public method

Starts the parsing process.
public parse ( ) : integer
return integer 1 if the parsing succeeded
Beispiel #1
0
 /**
  * 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();
 }
 /**
  * Creates the ExpatParser, sets root handler and kick off parsing
  * process.
  *
  * @throws BuildException if there is any kind of execption during
  *         the parsing process
  * @access private
  */
 protected function parse()
 {
     try {
         // get parse context
         $ctx = $this->project->getReference("phing.parsing.context");
         if (null == $ctx) {
             // make a new context and register it with project
             $ctx = new PhingXMLContext($this->project);
             $this->project->addReference("phing.parsing.context", $ctx);
         }
         //record this parse with context
         $ctx->addImport($this->buildFile);
         if (count($ctx->getImportStack()) > 1) {
             // this is an imported file
             // modify project tag parse behavior
             $this->setIgnoreProjectTag(true);
         }
         // push action onto global stack
         $ctx->startConfigure($this);
         $reader = new BufferedReader(new FileReader($this->buildFile));
         $parser = new ExpatParser($reader);
         $parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
         $parser->setHandler(new RootHandler($parser, $this));
         $this->project->log("parsing buildfile " . $this->buildFile->getName(), Project::MSG_VERBOSE);
         $parser->parse();
         $reader->close();
         // mark parse phase as completed
         $this->isParsing = false;
         // execute delayed tasks
         $this->parseEndTarget->main();
         // pop this action from the global stack
         $ctx->endConfigure();
     } catch (Exception $exc) {
         throw new BuildException("Error reading project file", $exc);
     }
 }
 /**
  * Creates the ExpatParser, sets root handler and kick off parsing
  * process.
  *
  * @throws BuildException if there is any kind of execption during
  *         the parsing process
  * @access private
  */
 protected function parse()
 {
     try {
         $reader = new BufferedReader(new FileReader($this->buildFile));
         $parser = new ExpatParser($reader);
         $parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
         $parser->setHandler(new RootHandler($parser, $this));
         $this->project->log("parsing buildfile " . $this->buildFile->getName(), Project::MSG_VERBOSE);
         $parser->parse();
         $reader->close();
     } catch (Exception $exc) {
         throw new BuildException("Error reading project file", $exc);
     }
 }
 /**
  * @param PhingXMLContext $ctx
  * @throws ExpatParseException
  */
 protected function _parse(PhingXMLContext $ctx)
 {
     // push action onto global stack
     $ctx->startConfigure($this);
     $reader = new BufferedReader(new FileReader($this->buildFile));
     $parser = new ExpatParser($reader);
     $parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
     $parser->setHandler(new RootHandler($parser, $this, $ctx));
     $this->project->log("parsing buildfile " . $this->buildFile->getName(), Project::MSG_VERBOSE);
     $parser->parse();
     $reader->close();
     // mark parse phase as completed
     $this->isParsing = false;
     // execute delayed tasks
     $this->parseEndTarget->main();
     // pop this action from the global stack
     $ctx->endConfigure();
 }