xml也加样式表……
(14:57) 三月 21st, 2008 by Hack38
今天无意中看着好玩儿……
发现XML也能加样式表,我的突然感觉到我以前的无知是多么的可笑……
下载: css.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://fucklenovo.com">
<channel>
<title><![CDATA[心灵境地]]></title>
<description><![CDATA[心灵境地]]></description>
<link>http://www.fucklenovo.com/</link>
<lastBuildDate>Fri, 21 Mar 2008 06:39:48 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, FuckLenovo Tech. Co., Ltd.</copyright>
<pubDate>Mon, 17 Mar 2008 13:03:50 GMT</pubDate>
<item>
<title><![CDATA[无语]]></title>
<link>http://fucklenovo.com/blog/1193500951</link>
<description><![CDATA[睡觉了。。没意思。。你玩你的。。我不想见你了。。以后也不要!]]></description>
<category><![CDATA[情感天地]]></category>
<author><![CDATA[@(心灵境地)]]></author>
<comments>http://fucklenovo.com/blog/1193500951#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Sat, 27 Oct 2007 16:02:31 GMT</pubDate>
<guid>http://fucklenovo.com/blog/1193500951</guid>
</item>
<item>
<title><![CDATA[[转]老婆的最后一条短信]]></title>
<link>http://fucklenovo.com/blog/1192274739</link>
<description><![CDATA[珍惜自己的所爱让更多的人学会珍惜!]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[@(心灵境地)]]></author>
<comments>http://fucklenovo.com/blog/1192274739#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Sat, 13 Oct 2007 11:25:39 GMT</pubDate>
<guid>http://fucklenovo.com/blog/1192274739</guid>
</item>
</channel>
</rss>
<?xml-stylesheet type="text/xsl" href="rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://fucklenovo.com">
<channel>
<title><![CDATA[心灵境地]]></title>
<description><![CDATA[心灵境地]]></description>
<link>http://www.fucklenovo.com/</link>
<lastBuildDate>Fri, 21 Mar 2008 06:39:48 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, FuckLenovo Tech. Co., Ltd.</copyright>
<pubDate>Mon, 17 Mar 2008 13:03:50 GMT</pubDate>
<item>
<title><![CDATA[无语]]></title>
<link>http://fucklenovo.com/blog/1193500951</link>
<description><![CDATA[睡觉了。。没意思。。你玩你的。。我不想见你了。。以后也不要!]]></description>
<category><![CDATA[情感天地]]></category>
<author><![CDATA[@(心灵境地)]]></author>
<comments>http://fucklenovo.com/blog/1193500951#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Sat, 27 Oct 2007 16:02:31 GMT</pubDate>
<guid>http://fucklenovo.com/blog/1193500951</guid>
</item>
<item>
<title><![CDATA[[转]老婆的最后一条短信]]></title>
<link>http://fucklenovo.com/blog/1192274739</link>
<description><![CDATA[珍惜自己的所爱让更多的人学会珍惜!]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[@(心灵境地)]]></author>
<comments>http://fucklenovo.com/blog/1192274739#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Sat, 13 Oct 2007 11:25:39 GMT</pubDate>
<guid>http://fucklenovo.com/blog/1192274739</guid>
</item>
</channel>
</rss>
下载: rss.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qz="http://fucklenovo.com">
<xsl:output encoding="utf-8" />
<xsl:template match="/rss">
<html>
<head>
<link href="css.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>
<xsl:element name="a">
<xsl:attribute name="href"> <xsl:value-of select="channel/link" /> <xsl:value-of select="channel/description" /> </xsl:attribute>
<xsl:value-of select="channel/title" />
</xsl:element>
</h1>
<h2> <xsl:value-of select="channel/description" /> </h2>
<div class="rss_main">
<xsl:for-each select="channel/item">
<h3>
<xsl:element name="a">
<xsl:attribute name="href"> http://fucklenovo.com/blog/<xsl:value-of select="substring-after(substring-before(link,'.'),'//')"/>-<xsl:value-of select="substring-after(substring-after(substring-after(link,'//'),'/'),'/')"/> </xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
</h3>
<div class="rss_item_date"><xsl:value-of select="pubDate" /></div>
<div class="rss_content"><xsl:value-of select="description" disable-output-escaping="yes" /> </div>
</xsl:for-each>
</div>
<div class="copyright"> <xsl:value-of select="channel/copyright" /> </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qz="http://fucklenovo.com">
<xsl:output encoding="utf-8" />
<xsl:template match="/rss">
<html>
<head>
<link href="css.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>
<xsl:element name="a">
<xsl:attribute name="href"> <xsl:value-of select="channel/link" /> <xsl:value-of select="channel/description" /> </xsl:attribute>
<xsl:value-of select="channel/title" />
</xsl:element>
</h1>
<h2> <xsl:value-of select="channel/description" /> </h2>
<div class="rss_main">
<xsl:for-each select="channel/item">
<h3>
<xsl:element name="a">
<xsl:attribute name="href"> http://fucklenovo.com/blog/<xsl:value-of select="substring-after(substring-before(link,'.'),'//')"/>-<xsl:value-of select="substring-after(substring-after(substring-after(link,'//'),'/'),'/')"/> </xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
</h3>
<div class="rss_item_date"><xsl:value-of select="pubDate" /></div>
<div class="rss_content"><xsl:value-of select="description" disable-output-escaping="yes" /> </div>
</xsl:for-each>
</div>
<div class="copyright"> <xsl:value-of select="channel/copyright" /> </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
下载: css.css
body{
/*font:normal normal normal 62.5%/1.5em Microsoft Yahei, Simsun, Verdana, Arial, Helvetica, sans-serif;*/
font:normal normal normal 62.5%/1.5em Simsun, Verdana, Arial, Helvetica, sans-serif;
text-align:center;
background:#FBFBFB;
margin:0;
}
h1,h2,div{
text-align:left;
font-size:1.1em;
width:80%;
margin:0 auto;
}
h1,h2,h3{
margin:0;
}
h1{
font:bold 3em/1.6em;
margin-top:30px;
}
h1 a{
color:#666666;
text-decoration:none;
}
h2{
font:1.2em/2em;
margin-bottom:2em;
}
.tip{
color:#444444;
font:1.2em/1.2em;
background:#FFFFCC;
text-indent:1em;
line-height:24px;
height:24px;
border-bottom:1px solid #FFBD00;
position:absolute;
top:0;
left:0;
width:100%;
}
.rss_main h3{
font:bold 1.3em/1.6em;
margin:6px 0;
border-bottom:2px solid #E1E1E1;
}
.rss_main h3 a{
color:#3F92ED;
text-decoration:none;
}
.rss_item_date{
margin:5px 0 10px;
padding-left:.3em;
border-left:3px solid #E1E1E1;
}
.rss_content{
color:#666666;
font:1.2em/1.5em;
width:96%;
margin-bottom:16px;
}
.rss_content a{
color:#3F92ED;
}
.copyright{
color:#666666;
font:.9em/2em Verdana;
margin:5px 0 10px;
border-top:2px solid #E1E1E1;
}
/*font:normal normal normal 62.5%/1.5em Microsoft Yahei, Simsun, Verdana, Arial, Helvetica, sans-serif;*/
font:normal normal normal 62.5%/1.5em Simsun, Verdana, Arial, Helvetica, sans-serif;
text-align:center;
background:#FBFBFB;
margin:0;
}
h1,h2,div{
text-align:left;
font-size:1.1em;
width:80%;
margin:0 auto;
}
h1,h2,h3{
margin:0;
}
h1{
font:bold 3em/1.6em;
margin-top:30px;
}
h1 a{
color:#666666;
text-decoration:none;
}
h2{
font:1.2em/2em;
margin-bottom:2em;
}
.tip{
color:#444444;
font:1.2em/1.2em;
background:#FFFFCC;
text-indent:1em;
line-height:24px;
height:24px;
border-bottom:1px solid #FFBD00;
position:absolute;
top:0;
left:0;
width:100%;
}
.rss_main h3{
font:bold 1.3em/1.6em;
margin:6px 0;
border-bottom:2px solid #E1E1E1;
}
.rss_main h3 a{
color:#3F92ED;
text-decoration:none;
}
.rss_item_date{
margin:5px 0 10px;
padding-left:.3em;
border-left:3px solid #E1E1E1;
}
.rss_content{
color:#666666;
font:1.2em/1.5em;
width:96%;
margin-bottom:16px;
}
.rss_content a{
color:#3F92ED;
}
.copyright{
color:#666666;
font:.9em/2em Verdana;
margin:5px 0 10px;
border-top:2px solid #E1E1E1;
}
1 Response to “xml也加样式表……”