这似乎不是开箱即用的,因为 RSS 2.0 的转换器忽略了(可选的)源元素。
您可以编写自己的转换器并根据项目的源属性自己设置源。我将值(来自您提要的“AP”)放入作者字段中:
public class MyConverterForRSS20 extends ConverterForRSS20 {
public MyConverterForRSS20() {
this("rss_2.0");
}
protected MyConverterForRSS20(String type) {
super(type);
}
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
Source source = item.getSource();
if (source != null) {
SyndFeed syndFeed = new SyndFeedImpl();
syndFeed.setLink(source.getUrl());
syndFeed.setAuthor(source.getValue());
syndEntry.setSource(syndFeed);
}
return syndEntry;
}
}
rome.properties
幸运的是,自定义转换器可以通过更改文件和设置MyConverterForRSS20
而不是com.sun.syndication.feed.synd.impl.ConverterForRSS20
(文件的最后一行)轻松插入 rome :
# Feed Conversor implementation classes
#
Converter.classes=com.sun.syndication.feed.synd.impl.ConverterForAtom10 \
com.sun.syndication.feed.synd.impl.ConverterForAtom03 \
com.sun.syndication.feed.synd.impl.ConverterForRSS090 \
com.sun.syndication.feed.synd.impl.ConverterForRSS091Netscape \
com.sun.syndication.feed.synd.impl.ConverterForRSS091Userland \
com.sun.syndication.feed.synd.impl.ConverterForRSS092 \
com.sun.syndication.feed.synd.impl.ConverterForRSS093 \
com.sun.syndication.feed.synd.impl.ConverterForRSS094 \
com.sun.syndication.feed.synd.impl.ConverterForRSS10 \
MyConverterForRSS20