Java生成Rdf

package com.ninemax.application.rss;

import com.rsslibj.elements.Channel;

public class Rdf {

	public static void main(String[] args) throws Exception {

		Channel channel = new Channel();
		channel.setDescription("This is my sample channel.");
		channel.setLink("/");
		channel.setTitle("MyChannel");
		channel.setImage("/", "TheChannelImage", "/foo.jpg");
		channel.setTextInput("/search", "SearchTheChannelImage",
				"TheChannelImage", "s");
		channel.addItem("/item1", "TheFirstItemcoversdetailsonthefirstitem>",
				"TheFirstItem").setDcContributor("JosephB.Ottinger");
		channel.addItem("/item2", "TheSecondItemcoversdetailsontheseconditem",
				"TheSecondItem").setDcCreator("JasonBell");
		System.out.println("The feed in RDF:" + channel.getFeed("rdf"));
	}
}

输出:

The feed in RDF:
<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns='http://purl.org/rss/1.0/'>
  <channel rdf:about='/'>
    <description>This is my sample channel.</description>
    <title>MyChannel</title>
    <link>/</link>
    <image rdf:resource='/foo.jpg'/>
    <textinput rdf:resource='/search'/>
    <items>
      <rdf:Seq>
        <li rdf:resource='/item1'/>
        <li rdf:resource='/item2'/>
      </rdf:Seq>
    </items>
  </channel>
  <image rdf:about='/foo.jpg'>
    <title>TheChannelImage</title>
    <link>/</link>
    <url>/foo.jpg</url>
  </image>
  <textinput rdf:about='/search'>
    <title>TheChannelImage</title>
    <link>/search</link>
    <description>SearchTheChannelImage</description>
    <name>s</name>
  </textinput>
  <item rdf:about='/item1'>
    <title>TheFirstItem</title>
    <link>/item1</link>
    <description>TheFirstItemcoversdetailsonthefirstitem&gt;</description>
    <dc:contributor>JosephB.Ottinger</dc:contributor>
  </item>
  <item rdf:about='/item2'>
    <title>TheSecondItem</title>
    <link>/item2</link>
    <description>TheSecondItemcoversdetailsontheseconditem</description>
    <dc:creator>JasonBell</dc:creator>
  </item>
</rdf:RDF>


你可能感兴趣的:(RDF)