[sync] WBXML status
Anthony Mills
amills at gascard.net
Thu Dec 4 22:22:49 PST 2003
Okay, patches included. Actually, fixed the namespaces, Decode is done for now.
The <cmd> ant the end is caused by a "\r" at the end of the http packet. 10
is <cmd> I think. Here is also the ContentHandler. It has a LifoQueue class
that is needed. I'll start on the encoder on Friday. Thanks,
Anthony
Quoting Chuck Hagenbuch <chuck at horde.org>:
> Quoting Anthony Mills <amills at gascard.net>:
>
> > Decoding is not perfect, but I think it will work. The two main
> > problems are name spaces and opaque data. The names spaces I can fix,
> > but they are mostly ignored anyway. The opaque data is more important.
> > iCalanders and such are sent as opaque data. So is DefInf data.
> > DevInf data is actually another WBXML file inbeded into the WBXML file.
> > It's nested. Given the way php handles binary we can send the opaque
> > data just like it was a string, but it then makes XML invalid. We
> > probably want to use some sort of event XML, I know I keep bring it up,
> > but this is why. The encoder needs this too, because of opaque data.
> > So, I am going to change the Decoder slightly, to use events. I'm
> > actually going to use XML_WBXML_ContentHandler in Decoder for both
> > encoding and decoding. So if you actuall read this far, it means I'm
> > going work on the encoder and get WBXML work both ways, using
> > XML_WBXML_ContentHandler as the interface.
>
> Sounds fine to me - XML_WBXML_ContentHandler should probably move to its own
> file in XML/WBXML/ContentHandler.php, then. I'll leave this to you until the
> next round of patches comes in, and then I'll take a look and help as I can.
> Okay?
>
> -chuck
>
> --
> Charles Hagenbuch, <chuck at horde.org>
> "I'm really... I'm not too fascinated by green food." - Average Joe
>
> --
> sync mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: sync-unsubscribe at lists.horde.org
>
>
-------------- next part --------------
<?php
/**
* $Horde: framework/XML_WBXML/WBXML/Decoder.php,v 1.7 2003/12/04 14:56:00 chuck Exp $
*
* Copyright 2003 Anthony Mills <amills at pyramid6.com>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* From Binary XML Content Format Specification Version 1.3, 25 July
* 2001 found at http://www.wapforum.org
*
* @package XML_WBXML
*/
class XML_WBXML_ContentHandler {
var $_currenturi;
var $_indent = 0;
function XML_WBXML_ContentHandler() {
$this->_currenturi = new XML_WBXML_LifoQueue();
}
function startElement($uri, $element, $attrs)
{
$this->_padspaces();
echo '<' . $element;
$currenturi = $this->_currenturi->top();
//print("[" . $currenturi . "] (" . $uri . ")");
if ((!$currenturi) || ($currenturi != $uri)) {
echo ' xmlns="' . $uri . '"';
}
$this->_currenturi->push($uri);
//print("{" . $this->_currenturi->top() . "}");
foreach ($attrs as $attr) {
echo ' ' . $attr['attiribute'] . '="' . $attr['value'] . '"';
}
echo ">\n";
$this->_indent++;
}
function endElement($element)
{
$this->_indent--;
$this->_padspaces();
echo '</' . $element . ">\n";
$this->_currenturi->pop();
}
function characters($str)
{
$this->_padspaces();
echo $str . "\n";
}
function opaque($o)
{
}
/**
* Padding to make it easier to read.
*/
function _padspaces()
{
if ($this->_indent > 0) {
echo str_repeat(' ', $this->_indent);
}
}
}
class XML_WBXML_LifoQueue {
var $_queue = array();
var $_num;
function XML_WBXML_LifoQueue()
{
$this->_num = 0;
}
function push($obj)
{
//debug
//print('push("' . $obj . '", ' . $this->_num . ')');
$this->_queue[$this->_num] = $obj;
$this->_num++;
}
function pop()
{
if ($this->_num > 0) {
$obj = $this->_queue[$this->_num - 1];
$this->_num--;
//debug
//print('pop("' . $obj . '")');
return $obj;
} else {
return false;
}
}
function top()
{
if ($this->_num > 0) {
return $this->_queue[$this->_num - 1];
} else {
return false;
}
}
}
?>
-------------- next part --------------
? ContentHandler.txt
? patch.txt
? WBXML/ContentHandler.php
Index: WBXML/Decoder.php
===================================================================
RCS file: /repository/framework/XML_WBXML/WBXML/Decoder.php,v
retrieving revision 1.7
diff -u -r1.7 Decoder.php
--- WBXML/Decoder.php 4 Dec 2003 14:56:00 -0000 1.7
+++ WBXML/Decoder.php 5 Dec 2003 06:15:53 -0000
@@ -2,6 +2,7 @@
include_once 'XML/WBXML.php';
include_once 'XML/WBXML/DTDManager.php';
+include_once 'XML/WBXML/ContentHandler.php';
/**
* $Horde: framework/XML_WBXML/WBXML/Decoder.php,v 1.7 2003/12/04 14:56:00 chuck Exp $
@@ -295,6 +296,8 @@
$size = XML_WBXML::MBUInt32ToInt($input);
$b = fread($input, $size);
+ $this->_ch->opaque($b);
+
// FIXME Opaque is used by SYNCML. Opaque data that depends on the context
// if (contentHandler instanceof OpaqueContentHandler) {
// ((OpaqueContentHandler)contentHandler).opaque(b);
@@ -571,52 +574,4 @@
}
-class XML_WBXML_ContentHandler {
-
- var $_currenturi;
- var $_indent = 0;
-
- function startElement($uri, $element, $attrs)
- {
- $this->_padspaces();
- echo '<' . $element;
-
- if ((empty($this->_currenturi)) || ($this->_currenturi != $uri)) {
- echo ' xmlns="' . $uri . '"';
- $this->_currenturi = $uri;
- }
-
- foreach ($attrs as $attr) {
- echo ' ' . $attr['attiribute'] . '="' . $attr['value'] . '"';
- }
-
- echo ">\n";
-
- $this->_indent++;
- }
-
- function endElement($element)
- {
- $this->_indent--;
-
- $this->_padspaces();
- echo '</' . $element . ">\n";
- }
-
- function characters($str)
- {
- $this->_padspaces();
- echo $str . "\n";
- }
-
- /**
- * Padding to make it easier to read.
- */
- function _padspaces()
- {
- if ($this->_indent > 0) {
- echo str_repeat(' ', $this->_indent);
- }
- }
-
-}
+?>
Index: docs/examples/decode.php
===================================================================
RCS file: /repository/framework/XML_WBXML/docs/examples/decode.php,v
retrieving revision 1.3
diff -u -r1.3 decode.php
--- docs/examples/decode.php 4 Dec 2003 14:57:45 -0000 1.3
+++ docs/examples/decode.php 5 Dec 2003 06:15:53 -0000
@@ -8,8 +8,9 @@
$decoder = &new XML_WBXML_Decoder();
-$input = fopen('syncml_client_packet_1.wbxml', 'rb');
+$input = fopen('syncml_server_packet_1.wbxml', 'rb');
$decoder->decode($input);
fclose($input);
+
More information about the sync
mailing list