RSS配信の件数指定

「まったく何も分からない・・・」そんなユーザーさんの為のフォーラムです。どんなご質問でもお気軽にどうぞ。
返信
ryo-tsuboya
アクティブユーザー
記事: 10
登録日時: 2006年12月01日(金) 19:21

RSS配信の件数指定

投稿記事 by ryo-tsuboya » 2007年3月12日(月) 12:22

こんにちは。RSS配信をやってみたのですが、登録しているすべてのニュースが配信されてしまします。これを5件のみ、と指定したいのですが、やり方がよくわかりません。

質問フォーラムを検索してみたところ、デザイン定義ファイルに、

<xsl:for-each select="rss:item">
<xsl:if test="position()<=5">
 この中に記事の出力処理を書く
</xsl:if>
</xsl:for-each>

を貼り付ければOK、と書いてありました。デザイン定義ファイルは、具体的には以下のどこを貼りかえればよろしいのでしょうか?

よろしくお願いいたします。

------------------------------------------------------

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
version="1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sy = "http://purl.org/rss/1.0/modules/syndication/"
xmlns:dc = "http://purl.org/dc/elements/1.1/"
xmlns:xh = "http://www.w3.org/1999/xhtml"
xmlns = "http://purl.org/rss/1.0/" >

<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no" />

<xsl:variable name="baseUrl" select="'http://www.xxx.net/RSS/'" />
<xsl:variable name="index" select="concat($baseUrl, 'testindex.php')" />
<xsl:variable name="rdfphp" select="concat($baseUrl, 'topnewsrss.php')" />
<xsl:variable name="entryphp" select="concat($baseUrl, 'topnewsentry.php')" />
<xsl:variable name="title" select="'RSSテスト'" />
<xsl:variable name="description" select="'RSSテストです。'" />
<xsl:variable name="subject" select="'お知らせ'" />

<xsl:template match="/entrylist">

<rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:lang="ja">

<channel rdf:about="{$index}">
<title><xsl:value-of select="$title" /></title>
<link><xsl:value-of select="$index" /></link>
<description><xsl:value-of select="$description" /></description>
<items>
<rdf:Seq>

<xsl:for-each select="entry">

<rdf:li rdf:resource="{$entryphp}{@href}"/>

</xsl:for-each>

</rdf:Seq>
</items>
</channel>

<xsl:for-each select="entry">

<item rdf:about="{$entryphp}{@href}">
<title><xsl:value-of select="title" /></title>
<link><xsl:value-of select="concat($entryphp,@href)" /></link>
<description><xsl:value-of select="description" /></description>
<dc:date><xsl:value-of select="@year" />-<xsl:value-of select="@month" />-<xsl:value-of select="@day" />T<xsl:value-of select="@hour" />:<xsl:value-of select="@minute" />:<xsl:value-of select="@second" />+09:00</dc:date>
<dc:subject><xsl:value-of select="$subject" /></dc:subject>
</item>

</xsl:for-each>

</rdf:RDF>

</xsl:template>
</xsl:stylesheet>
------------------------------------------------------

webmaster
Site Admin
記事: 1451
登録日時: 2004年12月10日(金) 10:09

Re: RSS配信の件数指定

投稿記事 by webmaster » 2007年3月14日(水) 17:50

 ryo-tsuboyaさん、ご質問ありがとうございます。

 RSS配信、とのことで、おそらく検索された結果の内容は「RSS受信」です。

 RSS配信の場合には、通常のエントリ一覧の出力と同じ仕組みを利用して
おりますので、cmsd:entrylistタグのrows属性に5と指定して頂ければOKです。
 この指定は配信用のphpファイル側の指定になります。

 <cmsd:entrylist name="mydiary" design="rss" output="rss" rows="5" />

 デザイン定義側でも5件絞込みさせることは可能ですが、パフォーマンス的に
あまりよくない為、この方法でお試し下さい。

ryo-tsuboya
アクティブユーザー
記事: 10
登録日時: 2006年12月01日(金) 19:21

投稿記事 by ryo-tsuboya » 2007年3月15日(木) 10:14

なるほど!普通にやればいいんですね!

ありがとうございます!

返信