# wddx class mapping and pretty print

- Thread: https://externals.io/message/1015
- Original archive: https://news-web.php.net/php.internals/1015
- Started by Alan Knowles on 2003-04-23T12:47:07+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1015 — Alan Knowles — 2003-04-23T12:47:07+00:00

URL: https://externals.io/message/1015#1015

On one of those - xml is too difficult stints, I started thinking about 
using wddx as a generic storage system - perhaps thinking about things 
like MDB's data structure and the ability to load data..

I'm still thinking that it would be nice for wddx_deserialize to accept 
a stream - hence allowing the processing of huge xml files with minimal 
memory penalty..

This patch does 2 things.

a) a deserialize class mapping - so you can map stored classes into 
different instantation classes. (usefull when you dont have the original 
- or just want to map it to something else. - eg use the data with an 
extended class.


class tests_wddxtest {
    var $somearray = array(1,2,3);
    var $someassoc = array('dog'=>'cat','mouse'=>'cat');
    var $child;
    function test() {
        foreach($this->somearray as $i) {
            $this->child[] = new tests_wddxtest;
        }
    }
}

$x = new tests_wddxtest;
$x->test();

class silly {
    function __wakeup() {
       // echo "Construct silly";
        print_r($this);
        $this = null;
    }
}
$xx = wddx_serialize_value($x, "Testing X");
wddx_map_class(array('gtk_classviewer_tests_wddxtest'=> 'silly'));
$yy = wddx_deserialize($xx);
var_dump($yy);

in this example the wakup call can be used to commit to a database and 
free the memory :) - useful...

b) pretty printing of the xml so that it could be hand edited if need.. 
- or just semi-human readable..

wddx_set_indent(2);
$xx = wddx_serialize_value($x, "Testing X");
echo $xx;

Comments Anyone..???


Regards
Alan



-- 
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com




-- 
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com

---

## #1017 — Dan Kalowsky — 2003-04-23T16:13:54+00:00

URL: https://externals.io/message/1015#1017 · In reply to: #1015

> On one of those - xml is too difficult stints, I started thinking 
> about using wddx as a generic storage system - perhaps thinking about 
> things like MDB's data structure and the ability to load data..
>
> I'm still thinking that it would be nice for wddx_deserialize to 
> accept a stream - hence allowing the processing of huge xml files with 
> minimal memory penalty..
>
> This patch does 2 things.
>
> a) a deserialize class mapping - so you can map stored classes into 
> different instantation classes. (usefull when you dont have the 
> original - or just want to map it to something else. - eg use the data 
> with an extended class.

While I can't see myself using this it could be useful... once or twice.

> b) pretty printing of the xml so that it could be hand edited if 
> need.. - or just semi-human readable..

This I like.


Patch didn't look too bad either.

 >---------------------------------------------------------------<
Dan Kalowsky                    "Momma take this badge offa me,
http://www.deadmime.org/~dank    I can't use it anymore."
dank-nom@aps-deadmime.org        - "Knockin on Heavens Door",
kalowsky@php.net                        Bob Dylan
