Bug? REXML::UndefinedNamespaceException (Undefined prefix georss found):

811 views
Skip to first unread message

John Paul

unread,
Aug 10, 2010, 9:06:50 PM8/10/10
to gcal4ruby
When I am trying to load a calendar's events, I am getting this error:

REXML::UndefinedNamespaceException (Undefined prefix georss found):
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/parsers/baseparser.rb:389:in `pull'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/set.rb:195:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/set.rb:195:in `each_key'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/set.rb:195:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/parsers/baseparser.rb:387:in `pull'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/parsers/treeparser.rb:22:in `parse'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/document.rb:227:in `build'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/document.rb:43:in `initialize'
/Library/Ruby/Gems/1.8/gems/gdata4ruby-0.1.2/lib/gdata4ruby/
gdata_object.rb:107:in `new'
/Library/Ruby/Gems/1.8/gems/gdata4ruby-0.1.2/lib/gdata4ruby/
gdata_object.rb:107:in `load'
vendor/gems/gcal4ruby-0.5.6/lib/gcal4ruby/event.rb:301:in `load'
vendor/gems/gcal4ruby-0.5.6/lib/gcal4ruby/calendar.rb:120:in
`events'
vendor/gems/gcal4ruby-0.5.6/lib/gcal4ruby/calendar.rb:117:in `map'
vendor/gems/gcal4ruby-0.5.6/lib/gcal4ruby/calendar.rb:117:in
`events'

It only happens on one of the calendars I am working with but not the
others. This calendar is a Google App calendar. I was previously using
version 0.3.1 and didn't have this problem until I upgraded to 0.5.6

This is the XML that is creating the error
----------------

<entry xmlns:gCal='http://schemas.google.com/gCal/2005'
gd:kind='calendar#event' xmlns:app='http://www.w3.org/2007/app'
gd:etag='&quot;FksDTgZAeSp7IWA6WhJS&quot;' xmlns:docs='http://
schemas.google.com/docs/2007' xmlns:gd='http://schemas.google.com/g/
2005' xmlns:gAcl='http://schemas.google.com/acl/2007'
xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns='http://
www.w3.org/2005/Atom'><id>http://www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g%40group.calendar.google.com/events/ra1hl2vnb3319p518aqvc5g5ac</id><published>2010-08-05T13:46:49.000Z</published><updated>2010-08-05T13:46:57.000Z</updated><app:edited>2010-08-05T13:46:57.000Z</app:edited><category
term='http://schemas.google.com/g/2005#event' scheme='http://
schemas.google.com/g/2005#kind'/><title>Meeting w/ Mike X about
KarmaCRM</title><content/><link href='http://www.google.com/calendar/
event?
eid=cmExaGwydm5iMzMxOXA1MThhcXZjNWc1YWMga2FybWFjcm0uY29tX2c4OGQ2Z29lYTkwYzJxYWdyNm4zYzJybTVnQGc'
title='alternate' rel='alternate' type='text/html'/><link href='http://
www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g%40group.calendar.google.com/private/full/ra1hl2vnb3319p518aqvc5g5ac'
rel='self' type='application/atom+xml'/><link href='http://
www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g%40group.calendar.google.com/private/full/ra1hl2vnb3319p518aqvc5g5ac'
rel='edit' type='application/atom+xml'/><author><name>John Paul</
name><email>jnar...@gmail.com</email></
author><gd:comments><gd:feedLink href='http://www.google.com/calendar/
feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g
%40group.calendar.google.com/private/full/ra1hl2vnb3319p518aqvc5g5ac/
comments'/></gd:comments><gd:eventStatus value='http://
schemas.google.com/g/2005#event.confirmed'/><gd:where valueString='501
Avis Drive Ann Arbor, MI 48108'/><gd:who rel='http://
schemas.google.com/g/2005#event.organizer' valueString='KarmaCRM'
email='karmacrm.com_g88d6g...@group.calendar.google.com'/
><gd:when endTime='2010-08-16T14:00:00.000-04:00'
startTime='2010-08-16T13:30:00.000-04:00'/><gd:transparency
value='http://schemas.google.com/g/2005#event.opaque'/><gd:visibility
value='http://schemas.google.com/g/2005#event.default'/
><gCal:anyoneCanAddSelf value='false'/
><georss:where><gml:Point><gml:pos>42.213812 -83.734778</gml:pos></
gml:Point></georss:where><gCal:guestsCanInviteOthers value='true'/
><gCal:guestsCanModify value='false'/><gCal:guestsCanSeeGuests
value='true'/><gCal:sequence value='2'/><gCal:uid
value='ra1hl2vnb3319...@google.com'/></entry>

I am pretty sure it is because there is a location and it is including
some GEOcoding stuff...
<georss:where><gml:Point><gml:pos>42.213812 -83.734778</gml:pos></
gml:Point></georss:where>

------

Is this a GData gem issue or GCal4Ruby?
------

Thanks for an awesome gem and all the hard work, I love using it!

John Paul

unread,
Aug 10, 2010, 9:25:40 PM8/10/10
to gcal4ruby
I found the culprit and fixed it in the gdata4r gem.

I just added these two namespaces to
GData4Ruby::Utils.add_namespaces(entry)

entry.attributes["xmlns:georss"] = ""
entry.attributes["xmlns:gml"] = ""

It looks like Google has started sending these with Geo positioning
data.
> xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'xmlns='http://www.w3.org/2005/Atom'><id>http://www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n...</id><published>2010-08-05T13:46:49.000Z</published><updated>2010-08-05T13:46:57.000Z</updated><app:edited>2010-08-05T13:46:57.000Z</app:edited><category
> term='http://schemas.google.com/g/2005#event'scheme='http://
> schemas.google.com/g/2005#kind'/><title>Meeting w/ Mike X about
> KarmaCRM</title><content/><link href='http://www.google.com/calendar/
> event?
> eid=cmExaGwydm5iMzMxOXA1MThhcXZjNWc1YWMga2FybWFjcm0uY29tX2c4OGQ2Z29lYTkwYzJxYWdyNm4zYzJybTVnQGc'
> title='alternate' rel='alternate' type='text/html'/><link href='http://www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g...
> rel='self' type='application/atom+xml'/><link href='http://www.google.com/calendar/feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g...
> rel='edit' type='application/atom+xml'/><author><name>John Paul</
> name><email>jnarow...@gmail.com</email></
> author><gd:comments><gd:feedLink href='http://www.google.com/calendar/
> feeds/karmacrm.com_g88d6goea90c2qagr6n3c2rm5g
> %40group.calendar.google.com/private/full/ra1hl2vnb3319p518aqvc5g5ac/
> comments'/></gd:comments><gd:eventStatus value='http://
> schemas.google.com/g/2005#event.confirmed'/><gd:where valueString='501
> Avis Drive Ann Arbor, MI  48108'/><gd:who rel='http://
> schemas.google.com/g/2005#event.organizer' valueString='KarmaCRM'
> email='karmacrm.com_g88d6goea90c2qagr6n3c2r...@group.calendar.google.com'/><gd:when endTime='2010-08-16T14:00:00.000-04:00'
>
> startTime='2010-08-16T13:30:00.000-04:00'/><gd:transparency
> value='http://schemas.google.com/g/2005#event.opaque'/><gd:visibility
> value='http://schemas.google.com/g/2005#event.default'/><gCal:anyoneCanAddSelf value='false'/
> ><georss:where><gml:Point><gml:pos>42.213812 -83.734778</gml:pos></
>
> gml:Point></georss:where><gCal:guestsCanInviteOthers value='true'/><gCal:guestsCanModify value='false'/><gCal:guestsCanSeeGuests
>
> value='true'/><gCal:sequence value='2'/><gCal:uid
> value='ra1hl2vnb3319p518aqvc5g...@google.com'/></entry>

Mike Reich

unread,
Aug 10, 2010, 9:38:48 PM8/10/10
to gcal...@googlegroups.com
Hi John, thanks for the bug report. I'll get the new namespace added in the next version due out in the next couple of days here. The namespaces are kind of a moving target with Google - they don't really specify which will be returned, and unfortunately the REXML parser is pretty brittle and barfs if there is an unrecognized namespace. Pretty annoying. Anyhow, thanks for the fix!

-Mike

Mike Reich
Seabourne Consulting
mi...@seabourneconsulting.com
425-296-2440

John Paul Narowski

unread,
Aug 10, 2010, 9:54:36 PM8/10/10
to gcal...@googlegroups.com
Hi Mike,

Thanks for the ultra-quick response! I really appreciate what you're doing. I was amazed how little there was in the Ruby/Google API Arena. I might be able to help contribute a bit here and there possibly as I am using these gems in my CRM software (www.karmacrm.com) to integrate with Google Calendar and hopefully Google Docs down the road (thx to your other handy gem).

I will be pushing the gem to its full capacity as I am planning on offering full Google Calendar syncing to my users including recurring events ETC.

I noticed the GCal4Ruby::Recurrance class had a problem with the #load method based on what Google was returning so I overloaded it as follows:

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

#Accepts a string containing a properly formatted ISO 8601 recurrence rule and loads it into the recurrence object
def load(rec)
@frequency = {}
attrs = rec.split("\n")
attrs.each do |val|
key, value = val.split(":")
if key == 'RRULE'
value.split(";").each do |rr|
rr_key, rr_value = rr.split("=")
rr_key = rr_key.downcase.to_sym
unless @frequency.has_key?(rr_key)
if rr_key == :until
@repeat_until = Time.parse_complete(rr_value)
else
@frequency[rr_key] = rr_value
end
end
end
elsif key == 'INTERVAL'
@frequency[:inverval] = value.to_i
elsif key.include?("DTSTART;TZID")
@start_time = Time.parse_complete(value)
elsif key.include?("DTEND;TZID")
@end_time = Time.parse_complete(value)
end
end

end

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

With this I was able to build a hash that gave me all the recurrence rules I needed to build a proper recurring event using the IceCube library. This might not jive well with the rest of your code base (which I haven't gotten to yet) so I figured I would show you what I was thinking and maybe there is a way to incorporate the fix back into the code base.

Anyways good to chat with you and keep up the awesome work!

-JP

Reply all
Reply to author
Forward
0 new messages