[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-xml
Subject:    Re: Binary data w/ XML::Generator:DBI
From:       Robin Berjon <robin.berjon () expway ! fr>
Date:       2003-06-16 13:54:49
[Download RAW message or body]

brooks@deseret.com wrote:
> Quoting Robin Berjon (robin.berjon@expway.fr):
> This is the relevant section of code from X::G::D.  After a selected row has been
> retrieved from the database, the pattern below is what currently determines whether
> field contains binary data.
> 
> while ($sth->fetch) {
>         # TODO: Handle binary data
>         foreach (@row) {
>             if (defined($_) && /[\x00-\x08\x0A-\x0C\x0E-\x19]/) {
>                 # in foreach loops, $_ is an lvalue!
>                 $_ = MIME::Base64::encode_base64($_);
>             }
>         }
>         ...

Ok, that's simple enough :)

> Currently, if the field contains binary data you get something like 
> 
> <field1>.... base64 encoded data here ... </field1>
> 
> My simplistic approach was simply to add an attribute to the element that would
> produce output like
> 
> <field1 encoding="base64">.... base64 encoded data here ... </field1>
> 
> but I thought "that would be too easy"...there's probably an alternate
> approach that should be implemented.  Since I didn't know what that could be,
> I thought I'd post to the list.

No, it's that easy and it's the exact right thing to do :) I'm sure Matt will 
welcome a patch!

-- 
Robin Berjon <robin.berjon@expway.fr>
Research Engineer, Expway        http://expway.fr/
7FC0 6F5F D864 EFB8 08CE  8E74 58E6 D5DB 4889 2488

_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic