abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Rooney" <roo...@electricjellyfish.net>
Subject Re: Graceful handling of non-atom 1.0 feeds
Date Sun, 11 Jun 2006 16:10:29 GMT
On 6/10/06, James M Snell <jasnell@gmail.com> wrote:
> Abdera will successfully parse any well-formed XML.  The trick is not to
> use generics when parsing.
>
> Document doc = Parser.INSTANCE.parse(someInputStream);
>
> The parser will automatically detect whether the XML stream is an Atom
> document (Feed, Entry or Atom Publishing Protocol Introspection doc) or
> whether it is some other XML.
>
> Element element = doc.getRoot();
>
> if (element instanceof Feed) {
>   // it was an Atom Feed document }
> if (element instanceof Entry) {
>   // it was an Atom Entry document }
> if (element instanceof Service) {
>   // it was an APP Introspection document }
> if (element instanceof ExtensionElement) {
>   // it was arbitrary XML }
>
> More below.

Makes one wonder what the point of the generics is, if you can't use
them if you want to be able to recover gracefully from such
problems...

-garrett

Mime
View raw message