Exemplo n.º 1
0
 protected function _validate_template($text, $field_title)
 {
     try {
         $scanner = new XmlImportTemplateScanner();
         $tokens = $scanner->scan(new XmlImportStringReader($text));
         $parser = new XmlImportTemplateParser($tokens);
         $tree = $parser->parse();
     } catch (XmlImportException $e) {
         $this->errors->add('form-validation', sprintf(__('%s template is invalid: %s', 'wp_all_import_plugin'), $field_title, $e->getMessage()));
     }
 }
 /**
  * Creates new parser instance for text template specified
  *
  * @param string $xml
  * @param string $rootNodeXPath XPath for the record root node
  * @param string $template template
  * @param string &$file path to the cached template
  * @return XmlImportParser
  */
 public static function factory($xml, $rootNodeXPath, $template, &$file = NULL)
 {
     $scanner = new XmlImportTemplateScanner();
     $tokens = $scanner->scan(new XmlImportStringReader($template));
     $t_parser = new XmlImportTemplateParser($tokens);
     $tree = $t_parser->parse();
     $codegenerator = new XmlImportTemplateCodeGenerator($tree);
     $file = $codegenerator->generate();
     return new self($xml, $rootNodeXPath, $file);
 }