3. RSS 기술 소개 #3 - RSS 2.0 소개

Posted at 2007. 1. 21. 23:41 // in 기술정리 // by 김윤수



요즘 웹2.0의 기술 중 하나인 RSS가 여러모로 관심을 받고 있는 것 같습니다. 그래서 나름대로 정리해 볼 생각으로 글을 쓰게 됐습니다.

RSS에 대해 연재식으로 글을 쓰고 있고 이번에는 3.3. RSS 2.0 소개 차례입니다.

1. RSS 란 무엇인가 ?
2. RSS 활용
3. RSS 기술 소개
    3.1. RSS 역사
    3.2. RSS 1.0 소개
    3.3. RSS 2.0 소개
    3.4. ATOM 1.0 소개
4. RSS의 확장
    4.1. Podcast 소개: Podcast 란 무엇인가?
    4.2. OPML 소개
    4.3. MediaRSS 소개
5. RSS 발전 방향

지난 3.2. RSS 1.0 소개라는 글에서 RSS 1.0의 형식에 대해 알아 보았고, 이번에는 RSS 2.0의 형식에 대해 알아보도록 하겠습니다.

3.2. RSS 2.0 소개

RSS 2.0은 Really Simple Syndication의 약자로 RSS 1.0가 RDF Site Summary의 약자인 것과 다릅니다. RSS 2.0도 RSS 1.0 형식과 크게 다르지 않습니다. 이번에도 복잡한 Spec. 을 일일이 설명하기 보다는 예제로 설명드리도록 하겠습니다. 아래 예제의 굵은체에 주목을 하세요.

3.2.1. RSS 2.0 예제

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Liftoff News</title>
    <link>http://liftoff.msfc.nasa.gov/</link>
    <description>Liftoff to Space Exploration.</description>
    <language>en-us</language>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
    <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Weblog Editor 2.0</generator>
    <managingEditor>editor@example.com</managingEditor>
    <webMaster>webmaster@example.com</webMaster>

    <image>
      <url>http://blogfiles.naver.net/data6/2005/4/10/253/DSC03278.jpg</url>
      <title>Liftoff News</title>
      <link>http://liftoff.msfc.nasa.gov/</link>
    <image>

    <item>
      <title>Star City</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
      <description>How do Americans get ready to work with Russians aboard the
        International Space Station? They take a crash course in culture, language
        and protocol at Russia's Star City.</description>
      <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
    </item>

    <item>
      <title>Space Exploration</title>
      <link>http://liftoff.msfc.nasa.gov/</link>
      <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada
        will experience a partial eclipse of the Sun on Saturday, May 31st.</description>
      <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
    </item>
   
    <item>
      <title>The Engine That Does More</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
      <description>Before man travels to Mars, NASA hopes to design new engines
        that will let us fly through the Solar System more quickly.  The proposed
        VASIMR engine would do that.</description>
      <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
    </item>
   
    <item>
      <title>Astronauts' Dirty Laundry</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
      <description>Compared to earlier spacecraft, the International Space
        Station has many luxuries, but laundry facilities are not one of them.
        Instead, astronauts have other options.</description>
      <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
    </item>
  </channel>
</rss>

3.2.2. RSS 2.0 최상위 요소

RSS 2.0과 RSS 1.0의 가장 큰 차이점은 <channel> 요소와 <item> 요소의 분리 여부에 있습니다. 즉, RSS 1.0에서는 <channel> 요소 안에 <items>라는 TOC 역활을 하는 부분이 있고, <channel>과 독립적으로 <item> 요소가 존재하는 형식이었지만, RSS 2.0에서는 <channel> 요소 안에 <item> 이 포함되어 있습니다.

개발자 입장에서 본다면 RSS 1.0보다는 RSS 2.0이 더 바람직해 보입니다. 왜냐면 RSS 1.0은 <channel> 아래의 <items>에 기술된 내용과 <item> 각각을 서로 매치시켜야 하기 때문입니다. 굳이 <channel> 요소 안에 있는 <items> 같은 것들이 필요해 보이진 않습니다. RSS 2.0 은 이러한 작업이 필요없게 되었습니다.

RSS 2.0 문서의 가장 최상위에 있는 요소는 위에서 보듯이 <rss> 입니다. RSS 2.0에서 <rss> 요소는 namespace가 정의되어 있지 않습니다. 그리고, <rss> 요소 아래에는 <channel> 이라는 요소 하나만 존재합니다.

그리고, RSS 1.0은 rdf 형식을 따랐기 때문에 rdf:about 이라는 속성이 대부분의 요소에 있었는데요. RSS 2.0에서는 rdf:about 이라는 속성이 사용되지 않습니다. 솔직히 RSS 1.0에서 rdf:about 속성은 별로 쓸모는 없고 값이 잘못되었을 때, 까다로운 문제만 발생시킬 여지가 있는 것이었습니다.

최상위 요소들만 나타내다면 이렇게 되겠네요.

<?xml version="1.0"?>

<rss version="2.0">

  <channel>

    ......

  </channel>

</rss>


RSS 1.0은 다음과 같은 형식이었다는 것을 상기해 보세요.


<?xml version="1.0"?>


<rdf:RDF

  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

  xmlns="http://purl.org/rss/1.0/">

  <channel rdf:about="http://www.xml.com/xml/news.rss">

    ......

    <items>

    ......

    </items>

  </channel>

  ......

  <item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html">

  </item>

  <item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html">

  </item>

</rdf:RDF>


3.2.3. channel 요소

다음은 channel 요소에 대해 알아보겠습니다.


  <channel>
    <title>Liftoff News</title>
    <link>http://liftoff.msfc.nasa.gov/</link>
    <description>Liftoff to Space Exploration.</description>
    <language>en-us</language>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
    <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>Weblog Editor 2.0</generator>
    <managingEditor>editor@example.com</managingEditor>
    <webMaster>webmaster@example.com</webMaster>
    <image>......</image>

    <item>.......</item>

  </channel>

 

위에서 보시다 시피 channel 안에는 title, link, description, language, pubDate, lastBuildDate, docs, generator, managingEditor, webMaster 등 이 차례로 나옵니다. 이 중에 title, link, description 을 제외하고는 모두 선택 요소입니다. title, link, description 의 의미는 RSS 1.0에서의 의미와 동일하니 여기에서는 다루지 않겠습니다.


language는 채널이 쓰여진 언어를 나타냅니다.


pubDate는 채널이 출판된 날짜를 나타냅니다. 예를 들어, 일간 신문 같은 경우 매일 매일 출판되므로, 매 24시간마다 이 날짜가 바뀔 것입니다. 여기 나오는 형식은 모두 RFC 822를 따라야 하지만, 연도는 2글자로 써도 됩니다.


lastBuildDate는 채널이 마지막으로 갱신된 시간을 나타냅니다.


docs는 채널이 따르고 있는 RSS 규격의 URL을 나타냅니다.


generator는 채널 문서를 생성한 S/W를 나타냅니다. 이 값을 통해서 RSS 문서 생성을 위해 사용되는 S/W 종류에 대한 통계를 수집할 수 있을 것입니다.


managingEditor는 컨텐트 편집에 책임이 있는 사람의 e-mail 주소를 뜻합니다. 보통의 개인 블로그에는 큰 의미가 없겠지만 신문같은 미디어에는 의미가 있을 것입니다.


webMaster는 채널의 technical issue 를 책임지는 사람의 e-mail 주소를 뜻합니다. 이것도 보통의 개인 블로그에서는 별 의미가 없을 것입니다.


이 외에도 cloud, ttl, rating, skipDays, skipHours 등이 있으나 자주 쓰이는 필드가 아닌 것 같아서 자세한 설명은 RSS 2.0 규격 Spec 링크를 다는 것으로 대신하겠습니다.


마지막으로 image, item는 중요한 요소라서 아래에 따로 설명드리겠습니다.


3.2.4. image 요소


다음은 image 요소에 대해 알아보겠습니다.


    <image>
      <url>http://blogfiles.naver.net/data6/2005/4/10/253/DSC03278.jpg</url>
      <title>Liftoff News</title>
      <link>http://liftoff.msfc.nasa.gov/</link>
    <image>
 

image 요소는 전체적으로 보면 RSS feed 를 icon 으로는 어떻게 나타낼 것인가에 대한 정보를 가지고 있습니다. 당연히 가장 중요한 정보는 그 icon의 url이 될테구요. title 은 image 대신 나타낼 text를 나타냅니다. 그리고, url 은 image의 url 이구요, link 는 이미지를 클릭했을 때 가게될 site 주소를 나타냅니다. link 는 대부분 channel 의 홈 페이지이겠죠 ?


3.2.5. item 요소


다음은 item 요소에 대해 알아보겠습니다.


    <item>
      <title>Star City</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
      <description>How do Americans get ready to work with Russians aboard the
        International Space Station? They take a crash course in culture, language
        and protocol at Russia's Star City.</description>
      <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
    </item>


item 은 channel의 기사 또는 content 하나 하나를 나타냅니다. link는 해당 item 을 클릭했을 때 가게될, 보통은 기사 내용 전문을 볼 수 있는 URL을 뜻합니다. 때로는 이 description 안에 기사 내용 전문이 들어가게 되는 경우도 있습니다. pubDate는 기사가 출판된-또는 공개된- 시간을 뜻합니다. guid는 기사의 유일한 ID를 뜻합니다. RSS 2.0 문서를 보내는 쪽에서 이 ID가 유일하다는 걸 보장해야 합니다.


이 외에도 author, category, comment, enclosure, source 등이 정의되어 있으니 자세한 설명은  RSS 2.0 규격 Spec 링크를 참고하시기 바랍니다.


RSS 2.0 전체 요소 중 가장 중요한 요소라고도 할 수 있겠습니다.


3.2.6. naver blog 예제


<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
                   xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005"
                   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                   xmlns:dc="http://purl.org/dc/elements/1.1/"
                   xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/">
  <channel xmlns:cfi="http://www.microsoft.com/schemas/rss/core/2005/internal" cfi:lastdownloaderror="None">
    <title cf:type="text">S/W 개발에 대한 단상</title>
    <link>http://blog.naver.com/yesarangk</link>
    <image>
      <url>http://blogfiles.naver.net/data6/2005/4/10/253/크기변환_DSC03278.jpg</url>
      <title>S/W 개발에 대한 단상</title>
      <link>http://blog.naver.com/yesarangk</link>
    </image>
    <description cf:type="text">저는 소프트웨어 개발을 업으로 하는 사람입니다.</description>
    <language>ko</language>
    <copyright cf:type="text">Copyright(c) NHN Corp. All Rights Reserved.</copyright>
    <pubDate>Tue, 19 Dec 2006 14:37:58 GMT</pubDate>
    <lastBuildDate>Tue, 19 Dec 2006 14:37:58 GMT</lastBuildDate>
    <atom:updated>2006-12-19T14:37:58Z</atom:updated>

    <item>
      <category>기술동향</category>
      <title xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" cf:type="text">3. RSS 기술 소개 #1 - RSS 역사</title>
      <link>http://blog.naver.com/yesarangk/40032231861</link>
      <description xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" cf:type="html">요즘 웹2.0의 기술 중 하나인 RSS가 여러모로 관심을 받고 있는 것 같습니다. 그래서 나름대로 정리해 볼 생각으로 글을 쓰게 됐습니다.RSS에 대해 연재식으로</description>
      <pubDate>Mon, 18 Dec 2006 15:39:21 GMT</pubDate>
      <atom:published xmlns:atom="http://www.w3.org/2005/Atom">2006-12-18T15:39:21Z</atom:published>
      <atom:updated xmlns:atom="http://www.w3.org/2005/Atom">2006-12-18T15:39:21Z</atom:updated>
      <cfi:id>8</cfi:id>
      <cfi:read>true</cfi:read>
      <cfi:downloadurl>http://blog.rss.naver.com/yesarangk.xml</cfi:downloadurl>
      <cfi:lastdownloadtime>2006-12-19T14:37:59.156Z</cfi:lastdownloadtime>
    </item>

    <item>
      <category>S/W 개발</category>
      <title xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" cf:type="text">Programming Language Syntax 비교</title>
      <link>http://blog.naver.com/yesarangk/40032227962</link>
      <description xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" cf:type="html">정말 대단한 사람들... 그리고, 세상에 이렇게 많은 Programming 언어가 있는 줄 처음 알았음. 그 중에 진짜 내가 아는 건 몇 개 없음. http://merd.sourc</description>
      <pubDate>Mon, 18 Dec 2006 13:36:06 GMT</pubDate>
      <atom:published xmlns:atom="http://www.w3.org/2005/Atom">2006-12-18T13:36:06Z</atom:published>
      <atom:updated xmlns:atom="http://www.w3.org/2005/Atom">2006-12-18T13:36:06Z</atom:updated>
      <cfi:id>7</cfi:id>
      <cfi:read>true</cfi:read>
      <cfi:downloadurl>http://blog.rss.naver.com/yesarangk.xml</cfi:downloadurl>
      <cfi:lastdownloadtime>2006-12-19T14:37:59.156Z</cfi:lastdownloadtime>
    </item>
  </channel>
</rss>


naver는 RSS 2.0 형식에서 ATOM 과 Microsoft extension을 사용하네요. 특히 item 의 description에 cf:type="html" 이라고 해서 html이 그냥 쓰일 수 있게 한 점이 눈에 띄네요.


다음에는 3.3. ATOM 1.0 소개글을 통해 ATOM 1.0 형식에 대해 알아보도록 하겠습니다.