示例#1
0
 /**
  * initialize internal variables and write wbxml header to stream
  *
  * @param string $_urn
  * @todo check if dpi > 0, instead checking the urn
  */
 protected function _initialize($_dom)
 {
     $this->_dtd = Wbxml_Dtd_Factory::factory($_dom->doctype->name);
     $this->_codePage = $this->_dtd->getCurrentCodePage();
     // the WBXML version
     $this->_writeByte($this->_version);
     if ($this->_codePage->getDPI() === NULL) {
         // the document public identifier
         $this->_writeMultibyteUInt(1);
     } else {
         // the document public identifier
         // defined in string table
         $this->_writeMultibyteUInt(0);
         // the offset of the DPI in the string table
         $this->_writeByte(0);
     }
     // write the charSet
     $this->_writeCharSet($this->_charSet);
     if ($this->_codePage->getDPI() === NULL) {
         // the length of the string table
         $this->_writeMultibyteUInt(0);
     } else {
         // the length of the string table
         $this->_writeMultibyteUInt(strlen($this->_codePage->getDPI()));
         // the dpi
         $this->_writeString($this->_codePage->getDPI());
     }
 }
示例#2
0
 /**
  * the constructor will try to read all data until the first tag
  *
  * @param resource $_stream
  */
 public function __construct($_stream, $_dpi = NULL)
 {
     if (!is_resource($_stream) || get_resource_type($_stream) != 'stream') {
         throw new Exception('$_stream must be a stream');
     }
     if ($_dpi !== NULL) {
         $this->_dpi = $_dpi;
     }
     $this->_stream = $_stream;
     $this->_version = $this->_getByte();
     if (feof($this->_stream)) {
         throw new Wbxml_Exception_UnexpectedEndOfFile();
     }
     $this->_getDPI();
     $this->_getCharset();
     $this->_getStringTable();
     // resolve DPI as we have read the stringtable now
     // this->_dpi contains the string table index
     if ($this->_dpiType === Wbxml_Abstract::DPI_STRINGTABLE) {
         $this->_dpi = $this->_stringTable[$this->_dpi];
     }
     #$this->_dtd = Wbxml_Dtd_Factory::factory($this->_dpi);
     $this->_dtd = Wbxml_Dtd_Factory::factory(Wbxml_Dtd_Factory::ACTIVESYNC);
 }