3. RSS 기술 소개 #2 - RSS 1.0 소개

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



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

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

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.1. RSS 역사라는 글에서 RSS 역사에 대해 알아 보았습니다.

이번 글을 통해서는 RSS 1.0 형식에 대해 알아보도록 하겠습니다.

3.2. RSS 1.0 소개

RSS는 별로 복잡하지 않은 형식이라서 XML을 조금이라도 아시는 분은 한 번 보면 대충 이해하실 수 있습니다. 복잡한 Spec. 을 일일이 설명하기 보다는 예제로 설명드리도록 하겠습니다. 아래 예제의 파란색에 주목을 하세요.

3.2.1. 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">

    <title>XML.com</title>

    <link>http://xml.com/pub</link>

    <description>

      XML.com features a rich mix of information and services

      for the XML community.

    </description>

    <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" />

    <items>

      <rdf:Seq>

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

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

      </rdf:Seq>

    </items>

    <textinput rdf:resource="http://search.xml.com" />

  </channel>


  <image>rdf:about="http://xml.com/universal/images/xml_tiny.gif">

    <title>XML.com</title>

    <url>http://xml.com/universal/images/xml_tiny.gif</url>

    <link>http://www.xml.com</link>

  </image>


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

    <title>Processing Inclusions with XSLT</title>

    <link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link>

    <description>

     Processing document inclusions with general XML tools can be

     problematic. This article proposes a way of preserving inclusion

     information through SAX-based processing.

    </description>

  </item>


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

    <title>Putting RDF to Work</title>

    <link>http://xml.com/pub/2000/08/09/rdfdb/index.html</link>

    <description>

     Tool and API support for the Resource Description Framework

     is slowly coming of age. Edd Dumbill takes a look at RDFDB,

     one of the most exciting new RDF toolkits.

    </description>

  </item>


  <textinput rdf:about="http://search.xml.com">

    <title>Search XML.com</title>

    <description>Search XML.com's XML collection</description>

    <name>s</name>

    <link>http://search.xml.com</link>

  </textinput>


</rdf:RDF>

3.2.2. 최상위 요소들

RSS 1.0 문서의 가장 최상위에 있는 요소는 위에서 보듯이 rdf:RDF 입니다. RDF 앞에 붙은 rdf: 은 RDF 라는 tag의 namespace를 나타내는 것으로 RSS 0.9 버전과의 호환성을 위해서는 rdf: 로 써야 합니다-원래 XML namespace rule 에 따르면 이렇지 않습니다.

rdf:RDF 아래에 channel, image, item, textinput 등의 요소가 따라와야 합니다. 여기서 image 와 textinput 은 없어도 되구요, channel 은 한 개만, item 은 한 개 이상 올 수가 있습니다.

그도 그럴 것이 channel 은 RSS feed(또는 channel) 자체에 대한 설명이므로 꼭 하나만 있어야 될테구요, item 은 기사 항목 하나하나를 뜻 하므로 하나 이상 있어야 할 것입니다. 그리고, image 는 RSS channel 에 대한 image 또는 icon 으로 생각하시면 되는데, 언뜻 생각하기에도 없다고 해서 반드시 문제될 요소는 아닐 것입니다. 마지막으로 textinput 은 search 기능과 연결하기 위해 search 키워드를 입력할 수 있도록 하기 위해 사용됩니다. 없어도 괜찮을 것 같죠 ?

여기까지가 가장 최상위 요소들에 대한 설명입니다. 최상위 요소들은 보기 쉽게 파란색으로 나타냈습니다. 그러니까, 최상위 요소들만 나타내다면 이렇게 되겠네요.

<?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">

  </channel>

  <image rdf:about="http://xml.com/universal/images/xml_tiny.gif">

  </image>

  <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>

  <textinput rdf:about="http://search.xml.com">

  </textinput>

</rdf:RDF>


3.2.3. channel 요소


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


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

    <title>XML.com</title>

    <link>http://xml.com/pub</link>

    <description>

      XML.com features a rich mix of information and services

      for the XML community.

    </description>

    <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" />

    <items>

      <rdf:Seq>

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

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

      </rdf:Seq>

    </items>

    <textinput rdf:resource="http://search.xml.com" />

  </channel>


위에서 보시다 시피 channel 안에는 title, link, description, image, items, textinput 이 차례로 와야 합니다. 이 중에 image 와 textinput 을 제외하고는 모두 필수입니다. channel 요소에는 rdf:about 이라는 속성이 있는데, 이 속성에는 channel을 hosting 하는 홈페이지 주소나 RSS 파일자체의 URL이 옵니다.


channel 아래에 title 요소는 당연히 channel 의 제목이라고 생각하시면 되고, link는 보통은 RSS를 제공하는 홈페이지주소를 나타내고, description 은 channel 에 대한 간략한 설명이 나옵니다. image는 channel를 대표해줄 수 있는 icon의 url이 나옵니다. 이 url 은 앞에서 설명한 최상위 요소중 하나인 image 요소-rdf:RDF 요소 아래의 image 요소의 rdf:about 속성과 일치해야 합니다.


items 는 보통 문서의 TOC(Table Of Contents)라고 생각하시면 됩니다. RSS feed 의 content 목록을 나타내는 부분으로 rdf:li 요소 하나 하나가 개별 content를 나타내고, rdf:li의 resource속성의 값은 아래 3.2.5 에서 설명하는 item 요소의 rdf:about 속성의 값과 일치해야 합니다.


3.2.4. image 요소


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


  <image rdf:about="http://xml.com/universal/images/xml_tiny.gif">

    <title>XML.com</title>

    <url>http://xml.com/universal/images/xml_tiny.gif</url>

    <link>http://www.xml.com</link>

  </image>


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


3.2.5. item 요소


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


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

    <title>Processing Inclusions with XSLT</title>

    <link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link>

    <description>

     Processing document inclusions with general XML tools can be

     problematic. This article proposes a way of preserving inclusion

     information through SAX-based processing.

    </description>

  </item>


item 은 RSS feed의 기사 또는 content 하나 하나를 나타냅니다. link는 해당 item 을 클릭했을 때 가게될 보통은 기사 내용 전문을 볼 수 있는 URL을 뜻합니다. 때로는 이 description 안에 기사 내용 전문이 들어가게 되는 경우도 있습니다. 보통은 text 만 들어가기 때문에 기사 안에 이미지나 오디오, 동영상 등이 있을 경우에는 보이지 않을 수도 있습니다.


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


3.2.6. texinput 요소


이 요소는 실제적으로는 거의 쓰이지 않는 요소라서 별로 설명드려야할 필요성을 못 느끼겠네요. 그냥 search box 를 추가하는 정도라고 생각하시면 될 듯합니다. 제가 여기 저기 RSS feed에 가입해 봤지만 아직까지 search box 를 쓰는 곳은 본 적이 없습니다.


여기까지 설명 드린 것은 RSS 1.0의 기본 요소들이구요. 이 기본 요소들 외에 XML namespace를 이용하여 필요한 metadata를 확장할 수 있습니다-이걸 module 이라고 합니다. 현재 정의된 표준 module 들은 다음 네 가지 정도가 있습니다.

Dublin Core 는 content 자체에 대한 다양한 metadata를 나타내고, Syndication 은 배급 주기, 갱신 횟수, 갱신 기준 시각 등과 같이 배급에 관련된 정보를 나타냅니다. Content 는 content 자체의 encoding 형식을 나타내고, Taxonomy는 글의 카테고리에 대한 정보를 나타내는 데 주로 사용됩니다.

3.2.7. module 활용 예제

아래 예제는 module 까지 쓰고 있는 예제로 제 blog 가 RSS 1.0 으로 feeding 되고 있는 예입니다.

<?xml version="1.0" encoding="EUC-KR" ?>
<rdf:RDF
 xmlns="http://purl.org/rss/1.0/"
 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/"
 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" >
   
 <channel rdf:about="http://blog.rss.naver.com/blogRss.nhn?blogId=yesarangk&amp;rss=1.0">
  <title><![CDATA[S/W 개발에 대한 단상]]></title>
  <link>http://blog.naver.com/yesarangk</link>
  <description><![CDATA[저는 소프트웨어 개발을 업으로 하는 사람입니다.]]></description>
  <items>
   <rdf:Seq>
    <rdf:li resource="0" />
    <rdf:li resource="1" />
    <rdf:li resource="2" />
    ......

   </rdf:Seq>
  </items>
  <dc:date>Sat, 23 Dec 2006 23:17:16 +0900</dc:date>
  <dc:language>ko</dc:language>
  <dc:rights>Copyright(c) NHN Corp. All Rights Reserved.</dc:rights>
 </channel>
 <image rdf:about="http://blogfiles.naver.net/data6/2005/4/10/253/크기변환_DSC03278.jpg">
  <title><![CDATA[S/W 개발에 대한 단상]]></title>
  <url>http://blogfiles.naver.net/data6/2005/4/10/253/크기변환_DSC03278.jpg</url>
  <link>http://blog.naver.com/yesarangk</link>
 </image>
 <item rdf:about="0">
  <category><![CDATA[낙서장]]></category>
  <title><![CDATA[Merry Christmas & Happy New Year]]></title>
  <link>http://blog.naver.com/yesarangk/40032346162</link>
  <description><![CDATA[여기에 오시는 모든 분들 즐거운 성탄과 행복한 새해 맞이하시길 바랍니다. 새해에는 여러 분이 꿈꾸는 일들 모두 이루시길 바라고, 더욱 더 행복해지는 한 ]]></description>
  <dc:date>Thu, 21 Dec 2006 22:41:36 +0900</dc:date>
 </item>
 <item rdf:about="1">
  <category><![CDATA[기술동향]]></category>
  <title><![CDATA[3. RSS 기술 소개 #2 - RSS 1.0 소개]]></title>
  <link>http://blog.naver.com/yesarangk/40032271600</link>
  <description><![CDATA[요즘 웹2.0의 기술 중 하나인 RSS가 여러모로 관심을 받고 있는 것 같습니다. 그래서 나름대로 정리해 볼 생각으로 글을 쓰게 됐습니다.RSS에 대해 연재식으로 ]]></description>
  <dc:date>Tue, 19 Dec 2006 23:46:55 +0900</dc:date>
 </item>
 <item rdf:about="2">
  <category><![CDATA[기술동향]]></category>
  <title><![CDATA[3. RSS 기술 소개 #1 - RSS 역사]]></title>
  <link>http://blog.naver.com/yesarangk/40032231861</link>
  <description><![CDATA[요즘 웹2.0의 기술 중 하나인 RSS가 여러모로 관심을 받고 있는 것 같습니다. 그래서 나름대로 정리해 볼 생각으로 글을 쓰게 됐습니다.RSS에 대해 연재식으로 ]]></description>
  <dc:date>Tue, 19 Dec 2006 00:39:21 +0900</dc:date>
 </item>

 ......
</rdf:RDF>

namespace 상에는 여러 module 이 정의되어 있지만 정작 실제로 쓰이고 있는 module 은 Dublin Core module 만 쓰고 있네요. channel 요소의 items 의 rdf:li 요소의 resource 속성 값과 각 item 의 rdf:about 속성값이 서로 일치되어 있는 것에 유의하시기 바랍니다.

그리고, 신기한 건 item 요소 아래에 category 요소가 있다는 게 조금 이상하네요. RSS 1.0 에는 category 라는 요소는 정의되어 있지 않은데 말이죠. 아무래도 naver blog 에서 잘못 처리하고 있는 듯 합니다.

RSS 1.0 규격은 이곳에서 보실 수 있습니다.

다음에는 3.2. RSS 2.0 소개글을 통해 RSS 2.0 형식에 대해 알아보도록 하겠습니다.