01: /*
02: * Copyright 2004 Sun Microsystems, Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17: package com.sun.syndication.io.impl;
18:
19: import org.jdom.Document;
20: import org.jdom.Element;
21: import org.jdom.Namespace;
22: import com.sun.syndication.feed.WireFeed;
23:
24: /**
25: * To address issue with certain feeds (brought up by Charles Miller):
26: *
27: * "During the debacle that was the rollout of RSS2.0, this namespace was tried,
28: * and even appeared in Dave Winer's Scripting News feed for a while. It was
29: * then withdrawn, but the wonderful thing about standards is the moment you
30: * roll one out, even if it's marked as unfinished and subject to change,
31: * someone will end up stuck with it forever."
32: *
33: * Note that there is not counter part on the generator, we only generate the final RSS2
34: *
35: */
36: public class RSS20wNSParser extends RSS20Parser {
37: private static String RSS20_URI = "http://backend.userland.com/rss2";
38:
39: public RSS20wNSParser() {
40: this ("rss_2.0wNS");
41: }
42:
43: protected RSS20wNSParser(String type) {
44: super (type);
45: }
46:
47: public boolean isMyType(Document document) {
48: Element rssRoot = document.getRootElement();
49: Namespace defaultNS = rssRoot.getNamespace();
50: boolean ok = defaultNS != null
51: && defaultNS.equals(getRSSNamespace());
52: if (ok) {
53: ok = super .isMyType(document);
54: }
55: return ok;
56: }
57:
58: protected Namespace getRSSNamespace() {
59: return Namespace.getNamespace(RSS20_URI);
60: }
61:
62: /**
63: * After we parse the feed we put "rss_2.0" in it (so converters and generators work)
64: * this parser is a phantom.
65: *
66: */
67: protected WireFeed parseChannel(Element rssRoot) {
68: WireFeed wFeed = super .parseChannel(rssRoot);
69: wFeed.setFeedType("rss_2.0");
70: return wFeed;
71: }
72:
73: }
|