(月)

前回記事のとおりteeter totterを改造して生成させたsitemap.xmlに、XSLTスタイルシートを付ける事にした。
sitemap.xmlへダブリン・コアで各記事のタイトルやカテゴリ等を忍ばせたのはこのため。
まず、前回改造したmt_archive.plのサイトマップ生成サブルーチン(sub xml_archive)に次の太字部の一行を追加した。

# -------------------------------------------------------------------------
# パブリッシュ (sitemap.xmlファイル) 非UTF-8用はコメントアウト
# -------------------------------------------------------------------------

sub xml_archive {
open(OUT,">$set_data1[2]sitemap.xml") || &error("Write Error: sitemap.xml");
# if ($set_data2[41] eq "0" && $jc_check eq "pm") {
print OUT "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
# $code ="utf8";
# } elsif ($set_data2[41] eq "1") {
# print OUT "<?xml version=\"1.0\" encoding=\"euc-jp\" ?>\n";
# $code ="euc";
# } else {
# print OUT "<?xml version=\"1.0\" encoding=\"shift-jis\" ?>\n";
# $code ="sjis";
# }
print OUT "<?xml-stylesheet href=\"./sitemap.xsl\" type=\"text/xsl\"?>\n";
print OUT "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"";
print OUT " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
~以下略~

次に、過去記事で習得したXSLTスタイルシート(sitemap.xsl)をBOMなしUTF-8N・LF改行で作成し、ルートディレクトリにアップロード。
最後に、ルートディレクトリに「サイトマップ用CSSファイル名」とあるファイルを自作してアップロードすれば、人間が見てもわかるサイトマップになる。
問題は、利用規約違反にならないようインフォシーク iswebライトの広告をどうやって入れるかだ。
この問題に対しsitemap.xslでいろいろ試してみたが、今のところ失敗 (・∀・)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:site="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xml:lang="ja"
exclude-result-prefixes="xsl site dc"
version="1.0">
<xsl:output
indent="yes"
method="xml"
media-type="text/html"
omit-xml-declaration="no"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="UTF-8"/>

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<xsl:apply-templates select="site:urlset"/>
</html>
</xsl:template>

<xsl:template match="site:urlset">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta http-equiv="Content-Language" content="ja"/>
<meta name="classification">
<xsl:attribute name="content"><xsl:value-of select="site:url[1]/dc:subject"/></xsl:attribute>
</meta>
<meta name="author">
<xsl:attribute name="content"><xsl:value-of select="site:url[2]/dc:creator"/></xsl:attribute>
</meta>
<title><xsl:value-of select="site:url[1]/dc:title"/> | 全記事一覧</title>
<link rel="start">
<xsl:attribute name="type"><xsl:value-of select="site:url[1]/dc:format"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="site:url[1]/dc:title"/></xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="site:url[1]/site:loc"/></xsl:attribute>
</link>
<link rel="index" type="application/xml">
<xsl:attribute name="href"><xsl:value-of select="concat(site:url[1]/site:loc, 'sitemap.xml')"/></xsl:attribute>
</link>
<link rel="stylesheet" type="text/css">
<xsl:attribute name="href"><xsl:value-of select="concat(site:url[1]/site:loc, 'サイトマップ用CSSファイル名')"/></xsl:attribute>
</link>
<link rel="alternate" type="application/rdf+xml" title="RSS 1.0">
<xsl:attribute name="href"><xsl:value-of select="concat(site:url[1]/site:loc, 'index.rdf')"/></xsl:attribute>
</link>
</head>
<body>
<div id="banner">
<h1 id="top">
<a>
<xsl:attribute name="href"><xsl:value-of select="site:url[1]/site:loc"/></xsl:attribute>
<xsl:value-of select="site:url[1]/dc:title"/>
</a> | <a>
<xsl:attribute name="href"><xsl:value-of select="concat(site:url[1]/site:loc, 'sitemap.xml')"/></xsl:attribute>全記事一覧
</a>
</h1>
<p class="description">
Last modified: <xsl:value-of select="substring-before(site:url[1]/site:lastmod, 'T')"/><br/>
Posted: <xsl:value-of select="site:url[2]/dc:creator"/>
</p>
</div>
<div class="blog">
<div class="blogbody">
<dl>
<dt>
<a>
<xsl:attribute name="href"><xsl:value-of select="site:url[1]/site:loc"/></xsl:attribute>
<xsl:value-of select="site:url[1]/dc:title"/>
</a>
</dt>
<dd>
<ul>
<xsl:apply-templates select="site:url[position() > 1]"/>
</ul>
</dd>
</dl>
<p class="top">▲<a href="#banner">Top</a></p>
</div>
</div>
</body>
</xsl:template>

<xsl:template match="site:url">
<li>
<span class="monospace">
<xsl:value-of select="substring-before(site:lastmod, 'T')"/>
</span>:
<a rel="bookmark">
<xsl:attribute name="href"><xsl:value-of select="site:loc"/></xsl:attribute>
<xsl:value-of select="dc:title"/>
</a>
[<xsl:value-of select="dc:subject"/>]
</li>
</xsl:template>

</xsl:stylesheet>

追記: "site:url[position() > 1]"となっている部分については、"site:url[position() &gt; 1]"(&は半角)が正 <- teeter totterが勝手に変換しやがる...orz

Tags:

Posted by at 01:00+09:00
Categories: teeter totter | 楽天
Comments | Trackbacks

TopBottom

Trackbacks

Trackback URL:
http://ventura.pv.land.to/tt-cgi/tt_tb.cgi/124

TopBottom

Comments






保存しますか? Yes No


(URL以外は入力必須、過少コメント・連続投稿は不可)

TopBottom

< teeter totterでサイトマップXMLを出力 | Home