On 6/10/06, James M Snell <[EMAIL PROTECTED]> 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

Reply via email to