2011-02-12 65 views

回答

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> 
相关问题