# File lib/nanoc/helpers/xml_sitemap.rb, line 39
    def xml_sitemap(params={})
      require 'builder'

      # Extract parameters
      items = params[:items] || @items.reject { |i| i[:is_hidden] }

      # Create builder
      buffer = ''
      xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)

      # Check for required attributes
      if @site.config[:base_url].nil?
        raise RuntimeError.new("The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.")
      end

      # Build sitemap
      xml.instruct!
      xml.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') do
        # Add item
        items.each do |item|
          item.reps.reject { |r| r.raw_path.nil? }.each do |rep|
            xml.url do
              xml.loc         @site.config[:base_url] + rep.path
              xml.lastmod     item.mtime.to_iso8601_date unless item.mtime.nil?
              xml.changefreq  item[:changefreq] unless item[:changefreq].nil?
              xml.priority    item[:priority] unless item[:priority].nil?
            end
          end
        end
      end

      # Return sitemap
      buffer
    end