List-unsubscribe

"Kibaya E." <[email protected]> Thu, 10 Jul 2008 00:40:24 -0700 (PDT)
Newsgroups gmane.text.xml.rpc.specification
Message-ID <[email protected]>

--- On Thu, 7/10/08, Bill Moseley <[email protected]> wrote:

From: Bill Moseley <[email protected]>
Subject: Re: [xml-rpc] dateTime.iso8601 format
To: [email protected]
Date: Thursday, July 10, 2008, 3:04 AM






On Wed, Jul 09, 2008 at 08:34:02PM +0000, bryanh@giraffe- data.com wrote:
> 
> But tell me more about RPC::XML: in the mode where it _doesn't_
> present everything as a <string>, how do you see the
> <dateTime.iso8601> value? Still as the raw text? And if not, what
> happens with <dateTime.iso8601> today</dateTime. ios8601>?

Depends on how you use it. It's pretty limited, actually.

use strict;
use warnings;
use RPC::XML::Parser;
use Data::Dumper;

my $str = <<'';
<?xml version="1.0" ?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>foo</name>
<value>
<dateTime.iso8601> 2008-07-09T02: 14:02Z</dateTime .iso8601>
</value>
</member>
<member>
<name>bar</name>
<value>
<dateTime.iso8601> today</dateTime. iso8601>
</value>
</member>
<member>
<name>baz</name>
<value>
<int>123</int>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>

my $doc = RPC::XML::Parser- >new->parse( $str );

print Dumper $doc->value;

which returns a "RPC::XML::struct" object with three members.

$VAR1 = bless( {
'bar' => bless( do{\(my $o = 'today')}, 'RPC::XML::datetime _iso8601' ),
'baz' => bless( do{\(my $o = '123')}, 'RPC::XML::int' ),
'foo' => bless( do{\(my $o = '2008-07-09T02: 14:02Z')} , 'RPC::XML::datetime _iso8601' )
}, 'RPC::XML::struct' );

Now, you can call "value" on that and get a Perl data structure back:

print Dumper $doc->value- >value;

$VAR1 = {
'bar' => 'today',
'baz' => '123',
'foo' => '2008-07-09T02: 14:02Z'
};

So, as you can see, it does no validation. But, it is handy to
get a data structure like that back.

Now, in my case I have to validate every bit of data anyway, so an
invalid datetime will get caught[1].

> If I were doing an XML-RPC application in Perl, I'd want to see it
> as the same thing that time() returns (seconds-since- epoch).

Perl's DateTime objects are becoming very commonly used, so I'd be
inclined to want that -- but that should be a configuration option.
Epoch seconds do have their limitation -- sadly, I can't represent my
birthday in positive integer epoch seconds...

[1] In typical Perl fashion, a user of this RPC::XML module could
blindly use the data structure returned directly without further
validation and end up writing bad code.

In my case I have an application that accepts a hash of input data and
that data is always validated. At that level the application doesn't
know (or care) where the data comes from (XMLRPC request, HTTP POST,
cron job, etc.) so the fact that RPC::XML doesn't validate
isn't really a problem as it will get validated at the app level. In
other words, I get an unvalidated hash from HTTP POST and cron jobs
anyway.

In my XMLRPC responses I do want to be strict, though. I was joking
about sending everything as a <string>.

-- 
Bill Moseley
moseley@hank. org
Sent from my iMutt

 














      

[Non-text portions of this message have been removed]


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/xml-rpc/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/xml-rpc/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/