public function testEmpty()
 {
     $iterator = new TokenIterator([]);
     $this->assertNull($iterator->peek(0));
     $this->assertEquals(1, $iterator->getLineNumber());
     $this->assertEquals(1, $iterator->getColumnNumber());
 }
示例#2
0
 /**
  * 
  * @param type $path
  * @param \import\Schema $schema
  * @param \PDO $PDO
  */
 public function __construct($xmlPath, \import\Document $document)
 {
     parent::__construct($xmlPath, $document);
     $this->PDO = $this->document->getPDO();
     $this->id = $this->PDO->query("SELECT nextval('import_tmp_seq')")->fetchColumn();
     $query = $this->PDO->prepare("INSERT INTO import_tmp VALUES (?, ?)");
     $query->execute(array($this->id, preg_replace('/^[^<]*/', '', file_get_contents($this->xmlPath))));
 }
示例#3
0
 protected function next()
 {
     parent::next();
     if ($this->isCurrent('[', '(', '{')) {
         $this->depth++;
     } elseif ($this->isCurrent(']', ')', '}')) {
         $this->depth--;
     }
 }
示例#4
0
 /**
  * 
  * @param \utils\readContent\ReadContentInterface $xml
  * @param \import\Document $document
  * @param type $export should an export() call be available
  * @throws \RuntimeException
  */
 public function __construct($xmlPath, \import\Document $document, $export = false)
 {
     parent::__construct($xmlPath, $document);
     $this->reader = new \XMLReader();
     $tokenXPath = $this->document->getSchema()->getTokenXPath();
     if (!preg_match('|^//[a-zA-Z0-9_:.]+$|', $tokenXPath)) {
         throw new \RuntimeException('Token XPath is too complicated for XMLReader');
     }
     $this->tokenXPath = mb_substr($tokenXPath, 2);
     $nsPrefixPos = mb_strpos($this->tokenXPath, ':');
     if ($nsPrefixPos !== false) {
         $prefix = mb_substr($this->tokenXPath, 0, $nsPrefixPos);
         $ns = $this->document->getSchema()->getNs();
         if (isset($ns[$prefix])) {
             $this->tokenXPath = $ns[$prefix] . mb_substr($this->tokenXPath, $nsPrefixPos);
         }
     }
     if ($export) {
         $filename = tempnam(sys_get_temp_dir(), '');
         $this->outStream = new \SplFileObject($filename, 'w');
         $this->outStream->fwrite('<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n");
     }
 }
示例#5
0
 /**
  * 
  * @param type $path
  */
 public function __construct($xmlPath, \import\Document $document)
 {
     parent::__construct($xmlPath, $document);
 }