http://www.google.com/support/news_pub/bin/answer.py?answer=93992
是否有一种简单的方法来创建站点地图以支持Google新闻站点地图。我一直试图找到一种方法将<news:news>
包含在XSLT中,并且我一直在收到错误。
答案 0 :(得分:3)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<urlset>
<url>
<loc>http://www.example.org/business/article55.html</loc>
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:access>Subscription</news:access>
<news:genres>PressRelease, Blog</news:genres>
<news:publication_date>2008-12-23</news:publication_date>
<news:title>Companies A, B in Merger Talks</news:title>
<news:keywords>business, merger, acquisition, A,</news:keywords>
<news:stock_tickers>NASDAQ:A, NASDAQ:B</news:stock_tickers>
</news:news>
</url>
</urlset>
</xsl:template>
</xsl:stylesheet>
应用于任何XML输入(未使用)结果将是:
<?xml version="1.0" encoding="UTF-16"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>http://www.example.org/business/article55.html</loc>
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:access>Subscription</news:access>
<news:genres>PressRelease, Blog</news:genres>
<news:publication_date>2008-12-23</news:publication_date>
<news:title>Companies A, B in Merger Talks</news:title>
<news:keywords>business, merger, acquisition, A, B</news:keywords>
<news:stock_tickers>NASDAQ:A, NASDAQ:B</news:stock_tickers>
</news:news>
</url>
</urlset>