[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

why does rss/maker not raise errors?

Sam Roberts

11/12/2004 3:14:00 PM

There are lots of mandatory attributes (yes, which are mandatory is
documented on the wiki), but what is mandatory is different for
different RSS versions, and there are no errors raised, #make just
returns 'nil'. This caused me some trouble.

I hacked an extra line into this:

make/0.9.rb:22
if rss.channel
rss
else
+ raise "required channel or image properties are missing!"
nil
end

This isn't a real solution - it doesn't say what property is missing,
and only is in the 0.9 code, somebody who knew the code could do this
much better!

Also, what is "image"? I don't know what to put there, so I just put
some strings, and my RSS reader ignores them.


After I figured out the mandatory, it worked very well, thank you!

Sam


--- example ---
#!/opt/local/bin/ruby -w

require 'rss/maker'

#
# Remove ANY one of the property setting lines, and #make will return nil
# (without my example patch).
#

rss = RSS::Maker.make("0.9") do |maker|
maker.channel.title = "title"
maker.channel.link = "link"
maker.channel.description = "description"
maker.channel.language = "language"

maker.image.url = "maker.image.url"
maker.image.title = "maker.image.title"

item = maker.items.new_item
item.title = "item title"
item.link = "link"
end

puts rss.to_s



25 Answers

Francis Hwang

11/13/2004 12:39:00 AM

0


On Nov 12, 2004, at 10:14 AM, Sam Roberts wrote:
> Also, what is "image"? I don't know what to put there, so I just put
> some strings, and my RSS reader ignores them.

If you're producing RSS 0.9, I'd suggest looking here:
http://www.purplepages.ie/RSS/netscape/rs...

Looks like "image" is a non-mandatory tag. Personally I haven't seen
many aggregators that use them -- also the Netscape spec requires that
the image has to be 88 x 31 pixels, which seems mind-bogglingly
arbitrary to me -- so I'd leave them out, I suppose.

The RSS space is a bloody awful mess. I'll be glad when everybody moves
to Atom. (My own site included, but hey, I'm lazy.)

F.



Aredridel

11/13/2004 12:57:00 AM

0

> The RSS space is a bloody awful mess. I'll be glad when everybody moves
> to Atom. (My own site included, but hey, I'm lazy.)

Go RSS 1.0 and don't look back!

Rich metadata! Arbitrary info in feeds! It's not just XML!

Ari


Francis Hwang

11/13/2004 1:13:00 AM

0

Well, as far as I know every single version of RSS has at least one
glaring problem: It underspecifies what you're supposed to do if you
want to send XML tags in your <description>. So you end up doing bloody
awful things like actually _escaping_ your XML tags, and if you write a
blog about, say, XML (there are a few, I think), and you're emitting
escaped XML markers in your RSS code, you actually have to
_double-escape_ them to get them to show up in most aggregators:

<item>
<description>
Remember, when you're switching to XHTML, the BR tag needs to be
self-closing: &amp;lt;br /&amp;gt;
</description>
</item>

Aaaaaaaaargggggggggh.

And it doesn't really matter if any one version of RSS is decent,
because the whole RSS world is a bloody mess. You can try, for
convenience sake, to release a lib that's only compatible with RSS 1.0,
but people will find that really super-annoying. And RSS will never
move forward in any meaningful way, since there are actually _seven_
incompatible versions, put out by, I believe, three different
organizations, and the de-facto owner of RSS wants it to stop more or
less where it is.

Yesiree, I'm ready for Atom to hit big-time.

F.

On Nov 12, 2004, at 7:57 PM, Aredridel wrote:

>> The RSS space is a bloody awful mess. I'll be glad when everybody
>> moves
>> to Atom. (My own site included, but hey, I'm lazy.)
>
> Go RSS 1.0 and don't look back!
>
> Rich metadata! Arbitrary info in feeds! It's not just XML!
>
> Ari
>



James Britt

11/13/2004 1:40:00 AM

0

Francis Hwang wrote:
> Well, as far as I know every single version of RSS has at least one
> glaring problem: It underspecifies what you're supposed to do if you
> want to send XML tags in your <description>. So you end up doing bloody
> awful things like actually _escaping_ your XML tags, and if you write a
> blog about, say, XML (there are a few, I think), and you're emitting
> escaped XML markers in your RSS code, you actually have to
> _double-escape_ them to get them to show up in most aggregators:

Don't CDATA sections do it for you?

<item>
<description>
<![CDATA[
Remember, when you're switching to XHTML, the BR tag needs to be
self-closing: <br />
]]>
</description>
</item>



James


Francis Hwang

11/13/2004 2:15:00 AM

0


On Nov 12, 2004, at 8:39 PM, James Britt wrote:

> Francis Hwang wrote:
>> Well, as far as I know every single version of RSS has at least one
>> glaring problem: It underspecifies what you're supposed to do if you
>> want to send XML tags in your <description>. So you end up doing
>> bloody awful things like actually _escaping_ your XML tags, and if
>> you write a blog about, say, XML (there are a few, I think), and
>> you're emitting escaped XML markers in your RSS code, you actually
>> have to _double-escape_ them to get them to show up in most
>> aggregators:
>
> Don't CDATA sections do it for you?
>
> <item>
> <description>
> <![CDATA[
> Remember, when you're switching to XHTML, the BR tag needs to be
> self-closing: <br />
> ]]>
> </description>
> </item>
>

CDATA works, and it doesn't, more or less like escaping markup works,
but doesn't. Keep in mind that these days my main site is all XHTML and
I lean really hard on the basic conformance promise behind any XML
dialect. So I think it's pretty inelegant to put conformant XML (XHTML)
inside of conformant XML (RSS), but wrap it in an intermediate layer of
CDATA, which says "this stuff isn't necessarily well-formed anything."
I think it's a useful feature of XML that it will fall down and die
without being well-formed, but when you put stuff inside of CDATA
sections you don't get any of that benefit. (I'd go so far as to say
that if you are working in a domain where these sorts of conformance
concerns are not worth the hassle, you'd be better off using something
like YAML instead of XML.)

F.



Sam Roberts

11/13/2004 3:32:00 AM

0

It says it is optional here:

http://backend.userland....

Also, please refer to the DTD here:

http://my.netscape.com/publish/formats/rs...

Which says:

<!ELEMENT channel (title | description | link | language | item+ | rating? | image? | ...


Unless I completely misread the DTD, <image> is as optional as <rating>.

Could this be corrected, please?

Thanks!
Sam



Francis Hwang

11/13/2004 3:47:00 AM

0

Hey Sam,

One good place to report & track bugs is the new Ruby project on
Rubyforge:

http://rubyforge.org/pro...

F.

On Nov 12, 2004, at 10:32 PM, Sam Roberts wrote:

> It says it is optional here:
>
> http://backend.userland....
>
> Also, please refer to the DTD here:
>
> http://my.netscape.com/publish/formats/rs...
>
> Which says:
>
> <!ELEMENT channel (title | description | link | language | item+ |
> rating? | image? | ...
>
>
> Unless I completely misread the DTD, <image> is as optional as
> <rating>.
>
> Could this be corrected, please?
>
> Thanks!
> Sam
>
>



James Britt

11/13/2004 6:13:00 AM

0

Sam Roberts wrote:
> It says it is optional here:
>
> http://backend.userland....
>
> Also, please refer to the DTD here:
>
> http://my.netscape.com/publish/formats/rs...

Are you sure that rss/0.9 is not dealing with RSS 0.9?

http://my.netscape.com/publish/formats/r...

<!ELEMENT rdf:RDF (channel | image? | item+ | textinput?)*>

Same issue for the image element, though.


James


James Britt

11/13/2004 6:18:00 AM

0

Francis Hwang wrote:

>
>
> The RSS space is a bloody awful mess. I'll be glad when everybody moves
> to Atom. (My own site included, but hey, I'm lazy.)

The xml-dev list is having a nice discussion on Atom and RSS.

http://lists.xml.org/archives/xml-dev/200411/msg...

James
>
> F.
>
>
>



Aredridel

11/13/2004 6:27:00 AM

0

> > > Francis Hwang wrote:
> >> Well, as far as I know every single version of RSS has at least one
> >> glaring problem: It underspecifies what you're supposed to do if you
> >> want to send XML tags in your <description>. So you end up doing
> >> bloody awful things like actually _escaping_ your XML tags, and if
> >> you write a blog about, say, XML (there are a few, I think), and
> >> you're emitting escaped XML markers in your RSS code, you actually
> >> have to _double-escape_ them to get them to show up in most
> >> aggregators:

RSS 1.0 defines that. rdf:parseType='xmlliteral', or enclose in CDATA
or escaped entities. The first is preferred if the content is XML as
well.