You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Jarrod Stenberg <sl...@yahoo.com> on 2002/11/04 21:10:59 UTC

XML compression?

This is slightly off-topic, so please forgive me.   I
made a mod_perl module that outputs XML when given a
SQL aquery.  

The modules used:
XML::Generator::DBI
XML::Handler::YAWriter
XML::Parser::PerlSAX

There is a "text" field in the mysql database that is
coming back like so:

- <row>
  <id>87015</id> 
 
<body>QSByZWFsbHkgZ29vZCBidWRkeSBvZiBtaW5lIGNhbGxlZCBtZSB0aGUgb3RoZXIgZGF5IHRvIGxl
dCBtZSBrbm93IGhlIGhhZCBib3VnaHQgYSAnOTYgODU1dC4gSGUgaGFkIGEgJzg4IDc0NVQgYnV0
IHdhbnRlZCBhICdtb3JlJyByZWxpYWJsZSBjYXIuIEhlIHdpbGwgdGFraW5nIHNvbWUgY291cnNl
cyBzb29uIGFuZCBkb2Vzbid0IHdhbnQgdG8gaGF2ZSB0byByZXBhaXIgaXQgb3IgYmUgc3RyYW5k
ZWQuIEhlIGNhbGxlZCB0aGlzIG1vcm5pbmcgdG8gc2F5IGhlIHdvdWxkIGJlIGEgbGl0dGxlIGxh
dGUgdmlzaXRpbmcgbWUgc2luY2UgaGUgaGFkIGEgbWlub3Igc3RhcnRlZCBwcm9ibGVtLiBIZSBh
cnJpdmVkIGxhdGVyIGFuZCBkZXNjcmliZWQgaGlzIG1vcm5pbmcuIEl0J3MgcXVpZSBjb2xkIGFy
ZW91bmQgaGVyZSByaWdodCBub3cgYW5kIGhlIHdhcyB3b3JraW5nIG9uIGl0IG91dHNpZGUsIHdo
YXQgYSBtYW4uIEhlIHNhaWQgdGhlIHN0YXJ0ZXIgd2FzIGhhbmdpbmcgYSBsaXR0bGUgYW5kIGFm
dGVyIHRha2luZyBpdCBhcGFydCBmb3VuZCBpdCBuZWVkZWQgdG8gYmUgbHViZWQsIHdoaWNoIGhl
IGRpZCBhbmQgaXQgbm93IHdvcmtlcyBqdXN0IGZpbmUsIHRoYW5rIHlvdSB2ZXJ5IG11Y2guIEhl
IGFsc28gcG9pbnRlZCBvdXQgaXQgaGFkIGEgbmV3IGJhdHRlcnkgaW5zdGFsbGVkIGluIE5vdiBv
ZiAxOTk5IGFuZCB3YXMgdHJhZGVkIGluIERlYyBvZiAxOTk5LiBIZSBhbHNvIGdvdCBhIHJlYWxs
eSBnb29kIHByaWNlIGZvciBpdCB3aXRob3V0IGEgd2FycmFudGVlLCBhcm91bmQgJDE4ay4gV2Ug
ZGVjaWRlZCB0aGUgcHJldm91cyBvd25lciBoYWQgdHJpZWQgYSBuZXcgYmF0dGVyeSB0byBmaXgg
aGlzIHN0YXJ0ZXIgcHJvYmxlbSBhbmQgdGhhdCBub3Qgd29ya2luZywgZ2F2ZSB1cC4gVGhlIGRl
YWxlciBkaWRuJ3Qgd2FudCBhIHByb2JsZW0gY2FyIGFuZCAndW5sb2FkZWQnIGl0IG9uIG15IGZy
aWVuZC4gTXkgZnJpZW5kIGZpeGVkIGl0IGFuZCBub3cgaGFzIGEgcmVhbGx5IGdvb2QgY2FyIGNo
ZWFwLiBBbGwgdGhpcyB3aXRob3V0IHRoZSBCcmlja2JvYXJkLiBPbmUgbW9yYWwgb2YgdGhlIHN0
b3J5IGNvdWxkIGJlLCB0aGVyZSBhcmUgc3RpbGwgYmFyZ2FpbnMgdG8gYmUgaGFkIG91dCB0aGVy
ZSB0aGFua3MgdG8gc3R1cGlkIHBlb3BsZS4gT3IgYW5vdGhlciwgZml4IGl0IHlvcnNlbGYgYW5k
IHNhdmUuCi0tCndiYWluICc4NiA3NDRUaSBNNDYgPjIzM0ttaSwgJzk2IDk2NSA+NTBLbWkgd2lm
ZW1vYmlsZSwgbmVhciBNYW5hc3NhcyBWYS4=</body> 
  </row>

What the heck is this encoding?  The documentation
says nothing about compression.  I can't find anything
about this.

Thanks for any tips.
-Jarrod

__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: XML compression?

Posted by Jarrod Stenberg <sl...@yahoo.com>.
> To me this looks a lot like Base64 endcoding, which
> is not unsual in
> XML and Web Application context. So type 

Thanks.  I actually found where it was occuring,
XML/Generator/DBI.pm line 109:
        foreach (@row) {
            if (defined($_) &&
/[\x00-\x08\x0A-\x0C\x0E-\x19]/) {
                # in foreach loops, $_ is an lvalue!
                $_ = MIME::Base64::encode_base64($_);
            }
        }

The row is the data coming back from the DB handle. 
It seems the regex is not quite doing what it intends.
 This data is not binary, but just regular text (as
you found when you decoded it).  I'll probably just
comment out the line that encodes the data since I
won't need to move any binary data anyway.

Thanks for the help.

-Jarrod

__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: XML compression?

Posted by Axel Beckert - ecos gmbh <be...@ecos.de>.
Hi!

On Mon, Nov 04, 2002 at 12:10:59PM -0800, Jarrod Stenberg wrote:
> This is slightly off-topic, so please forgive me.   I
> made a mod_perl module that outputs XML when given a
> SQL aquery.  
> 
> The modules used:
> XML::Generator::DBI
> XML::Handler::YAWriter
> XML::Parser::PerlSAX
> 
> There is a "text" field in the mysql database that is
> coming back like so:
> 
> - <row>
>   <id>87015</id> 
>  
> <body>QSByZWFsbHkgZ29vZCBidWRkeSBvZiBtaW5lIGNhbGxlZCBtZSB0aGUgb3RoZXIgZGF5IHRvIGxl
> dCBtZSBrbm93IGhlIGhhZCBib3VnaHQgYSAnOTYgODU1dC4gSGUgaGFkIGEgJzg4IDc0NVQgYnV0
> IHdhbnRlZCBhICdtb3JlJyByZWxpYWJsZSBjYXIuIEhlIHdpbGwgdGFraW5nIHNvbWUgY291cnNl
> cyBzb29uIGFuZCBkb2Vzbid0IHdhbnQgdG8gaGF2ZSB0byByZXBhaXIgaXQgb3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5kIGZpeGVkIGl0IGFuZCBub3cgaGFzIGEgcmVhbGx5IGdvb2QgY2FyIGNo
> ZWFwLiBBbGwgdGhpcyB3aXRob3V0IHRoZSBCcmlja2JvYXJkLiBPbmUgbW9yYWwgb2YgdGhlIHN0
> b3J5IGNvdWxkIGJlLCB0aGVyZSBhcmUgc3RpbGwgYmFyZ2FpbnMgdG8gYmUgaGFkIG91dCB0aGVy
> ZSB0aGFua3MgdG8gc3R1cGlkIHBlb3BsZS4gT3IgYW5vdGhlciwgZml4IGl0IHlvcnNlbGYgYW5k
> IHNhdmUuCi0tCndiYWluICc4NiA3NDRUaSBNNDYgPjIzM0ttaSwgJzk2IDk2NSA+NTBLbWkgd2lm
> ZW1vYmlsZSwgbmVhciBNYW5hc3NhcyBWYS4=


> </body> 
>   </row>
> 
> What the heck is this encoding? 

To me this looks a lot like Base64 endcoding, which is not unsual in
XML and Web Application context. So type 

    perl -MMIME::Base64 -le '$/ = undef; print decode_base64(<>)'

cut & paste the above, and you'll get this:

A really good buddy of mine called me the other day to let me know he
had bought a '96 855t. He had a '88 745T but wanted a 'more' reliable
car. He will taking some courses soon and doesn't want to have to
repair it or be stranded. He called this morning to say he would be a
little late visiting me since he had a minor started problem. He
arrived later and described his morning. It's quie cold areound here
right now and he was working on it outside, what a man. He said the
starter was hanging a little and after taking it apart found it needed
to be lubed, which he did and it now workes just fine, thank you very
much. He also pointed out it had a new battery installed in Nov of
1999 and was traded in Dec of 1999. He also got a really good price
for it without a warrantee, around $18k. We decided the prevous owner
had tried a new battery to fix his starter problem and that not
working, gave up. The dealer didn't want a problem car and 'unloaded'
it on my friend. My friend fixed it and now has a really good car
cheap. All this without the Brickboard. One moral of the story could
be, there are still bargains to be had out there thanks to stupid
people. Or another, fix it yorself and save.

--
wbain '86 744Ti M46 >233Kmi, '96 965 >50Kmi wifemobile, near Manassas Va.

            Kind regards, Axel Beckert
-- 
-------------------------------------------------------------
Axel Beckert      ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     beckert@ecos.de         Voice:    +49 6133 926530
WWW:        http://www.ecos.de/     Fax:      +49 6133 925152
-------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org