Convert the sitemap into a string.
324562
def to_string(self):
        """"""
        root = etree.Element('urlset', nsmap={None: SITEMAP_NS})
        for url in self.urls:
            url.generate(root)
        return etree.tostring(root, pretty_print=True, xml_declaration=True,
                              encoding='utf-8')
190039
function generateSitemap(batfishConfig: BatfishConfiguration): Promise<void> {
  const sitemapWriter = fs.createWriteStream(
    path.join(batfishConfig.outputDirectory, 'sitemap.xml')
  );
  return new Promise((resolve, reject) => {
    sitemapWriter.on('error', reject);
    sitemapWriter.on('finish', () => resolve());

    sitemapStatic(sitemapWriter, {
      findRoot: batfishConfig.outputDirectory,
      prefix: joinUrlParts(
        String(batfishConfig.siteOrigin),
        String(batfishConfig.siteBasePath),
        ''
      ),
      pretty: true
    });
  });
}
1261509
def generate_output(self, writer):
        
        # write xml stylesheet
        with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:
            with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:
                xsl = fd_origin.read()
                # replace some template markers
                # TODO use pelican template magic
                xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))
                fd_destination.write(xsl)

        # will contain the url nodes as text
        urls = ''

        # get all articles sorted by time
        articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)

        # get all pages with date/modified date
        pages_with_date = list(
            filter(
                lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False),
                self.context.get('pages')
            )
        )
        pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)

        # get all pages without date
        pages_without_date = list(
            filter(
                lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None,
                self.context.get('pages')
            )
        )
        pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)

        # join them, first date sorted, then title sorted
        pages_sorted = pages_with_date_sorted + pages_without_date_sorted

        # the landing page
        if 'index' in self.context.get('DIRECT_TEMPLATES'):
            # assume that the index page has changed with the most current article or page
            # use the first article or page if no articles
            index_reference = None
            if len(articles_sorted) > 0:
                index_reference = articles_sorted[0]
            elif len(pages_sorted) > 0:
                index_reference = pages_sorted[0]

            if index_reference is not None:
                urls += self.__create_url_node_for_content(
                    index_reference,
                    'index',
                    url=self.url_site,
                )

        # process articles
        for article in articles_sorted:
            urls += self.__create_url_node_for_content(
                article,
                'articles',
                url=urljoin(self.url_site, article.url)
            )

        # process pages
        for page in pages_sorted:
            urls += self.__create_url_node_for_content(
                page,
                'pages',
                url=urljoin(self.url_site, page.url)
            )

        # process category pages
        if self.context.get('CATEGORY_URL'):
            urls += self.__process_url_wrapper_elements(self.context.get('categories'))

        # process tag pages
        if self.context.get('TAG_URL'):
            urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0].name))

        # process author pages
        if self.context.get('AUTHOR_URL'):
            urls += self.__process_url_wrapper_elements(self.context.get('authors'))

        # handle all DIRECT_TEMPLATES but "index"
        for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):
            # we assume the modification date of the last article as modification date for the listings of
            # categories, authors and archives (all values of DIRECT_TEMPLATES but "index")
            modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))
            url = self.__get_direct_template_url(direct_template)
            urls += self.__create_url_node_for_content(None, 'others', url, modification_time)

        # write the final sitemap file
        with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:
            fd.write(self.xml_wrap % {
                'SITEURL': self.url_site,
                'urls': urls
            })
669196
@Deprecated
	public void saveSitemap(File file, String[] sitemap) throws IOException {
		try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
			for (String string : sitemap) {
				writer.write(string);
			}
		}
	}
301666
def as_xml(self):
        
        self.default_capability()
        s = self.new_sitemap()
        return s.resources_as_xml(self, sitemapindex=self.sitemapindex)
328382
public Map<String, String> getSitePath() {

        if (m_sitePaths == null) {
            m_sitePaths = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {

                public Object transform(Object rootPath) {

                    if (rootPath instanceof String) {
                        return getRequestContext().removeSiteRoot((String)rootPath);
                    }
                    return null;
                }
            });
        }
        return m_sitePaths;
    }
938528
def to_string(self):
        
        builder = ""

        index = 0
        while index < self.__len__():
            if index > 0:
                builder = builder + ','
            builder = builder + super(ProjectionParams, self).__getitem__(index)
            index = index + 1

        return builder
497919
public String getSelectPath(CmsSitemapEntryBean sitemapEntry) {

        String normalizedSiteRoot = CmsStringUtil.joinPaths(CmsCoreProvider.get().getSiteRoot(), "/");
        String rootPath = sitemapEntry.getRootPath();
        if (rootPath.startsWith(normalizedSiteRoot)) {
            return rootPath.substring(normalizedSiteRoot.length() - 1);
        }
        return sitemapEntry.getRootPath();
    }
373714
def literal(target_url, options = {})
      metadata = Sitemap.configuration.params.clone.merge!(options[:metadata] || {})
      link = Sitemap.configuration.params.clone.merge!(options[:link] || {})
      search = Sitemap.configuration.search.clone.merge!(options.select { |k, v| SEARCH_ATTRIBUTES.keys.include?(k) })
      search.merge!(search) { |type, value| get_data(nil, value) }

      output_host =  options[:host] || host
      output_protocol = options[:protocol] || protocol
      self.store << {
        :url =>"#{output_protocol}://#{output_host}#{target_url}",
        :search => search,
        :metadata => metadata,
        :link => link
      }
    end
1330810
@Override
    public String[] toStringArray() {
        // auto-detect additional namespaces
        List<AdditionalNamespace> additionalNamespaces = new ArrayList<>();
        boolean hasImages = urls.values().stream()
                .anyMatch(webPage -> webPage.getImages() != null);
        if(hasImages) {
            additionalNamespaces.add(AdditionalNamespace.IMAGE);
        }
        boolean hasAlternateNames = urls.values().stream()
                .anyMatch(webPage -> webPage.getAlternateNames() != null);
        if(hasAlternateNames) {
            additionalNamespaces.add(AdditionalNamespace.XHTML);
        }

        ArrayList<String> out = new ArrayList<>();
        out.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        out.add("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"" + constructAdditionalNamespacesString(additionalNamespaces) + ">\n");
        ArrayList<WebPage> values = new ArrayList<>(urls.values());
        Collections.sort(values);
        for (WebPage webPage : values) {
            out.add("<url>\n");
            out.add(constructUrl(webPage));
            if (webPage.getImages() != null) {
                for (Image image : webPage.getImages()) {
                    out.add(constructImage(image));
                }
            }
            out.add("</url>\n");
        }
        out.add("</urlset>");
        return out.toArray(new String[]{});
    }
271027
String toText() {
    Map<String, Object> vars = toVars();
    return parsedTemplate().evaluate(vars);
  }
1099560
public function UpdateSitemap()
    {
        // Get url
        $url = $this->app->url();

        // Get basePath
        $basePath = $this->app->basePath();

        // Create sitemap
        $sitemap = new Sitemap($basePath.'/sitemap.xml');

        // Get all discussions
        $discussions = Discussion::whereVisibleTo(new Guest())->get();

        // Get all users
        $users = User::whereVisibleTo(new Guest())->get();

        // Add home
        $sitemap->addItem($url, time(), Sitemap::DAILY, 0.9);

        // Add users
        foreach ($users as $user) {
            $sitemap->addItem($url.'/u/'.$user->username, time(), Sitemap::DAILY, 0.5);
        }

        // Get all tags
        if (class_exists(Tag::class)) {
            $tags = Tag::whereVisibleTo(new Guest())->get();

            // Add tags
            foreach ($tags as $tag) {
                $sitemap->addItem($url.'/t/'.$tag->slug, time(), Sitemap::DAILY, 0.9);
            }
        }

        // Get all pages
        if (class_exists(Page::class)) {
            $pages = Page::all();

            //Add pages
            foreach ($pages as $page) {
                $sitemap->addItem($url.'/p/'.$page->id.'-'.$page->slug, time(), Sitemap::DAILY, 0.5);
            }
        }

        // Add discussions
        foreach ($discussions as $discussion) {
            $sitemap->addItem($url.'/d/'.$discussion->id.'-'.$discussion->slug, strtotime($discussion->last_time), Sitemap::DAILY, 0.7);
        }

        // Write
        $sitemap->write();
    }
522813
protected function getContent()
    {
        $this->currentURL = $this->urlEncode($this->currentURL);
        if (!$this->urlValidate($this->currentURL)) {
            throw new SitemapParserException('Invalid URL');
        }
        try {
            if (!isset($this->config['guzzle']['headers']['User-Agent'])) {
                $this->config['guzzle']['headers']['User-Agent'] = $this->userAgent;
            }
            $client = new GuzzleHttp\Client();
            $res = $client->request('GET', $this->currentURL, $this->config['guzzle']);
            return $res->getBody();
        } catch (GuzzleHttp\Exception\TransferException $e) {
            throw new SitemapParserException($e->getMessage());
        }
    }
845660
def sitemap(request):
    """"""
    xml = Sitemap()
    author = request.matchdict.get('from_id')
    if author is not None:
        match = "AND '{}' = authors[1]".format(author)
    else:
        match = ''

    with db_connect() as db_connection:
        with db_connection.cursor() as cursor:
            cursor.execute("""SELECT
                    ident_hash(uuid, major_version, minor_version)
                        AS idver,
                    name,
                    revised
                FROM latest_modules
                WHERE portal_type NOT IN ('CompositeModule', 'SubCollection')
                {}
                ORDER BY module_ident DESC""".format(match))
            res = cursor.fetchall()
            for ident_hash, page_name, revised in res:
                #  replace punctuation with whitespace
                page_name = re.sub(NON_WORD, ' ',
                                   page_name.decode('utf-8'), re.UNICODE)
                # remove leading and trailing whitespace
                page_name = page_name.strip().encode('utf-8')
                # replace spaces with dashes
                page_name = re.sub(' +', '-',
                                   page_name.decode('utf-8'), re.UNICODE)
                url = request.route_url('content',
                                        ident_hash=ident_hash,
                                        ignore=u'/{}'.format(page_name))
                if notblocked(url):
                    xml.add_url(url, lastmod=revised)

    resp = request.response
    resp.status = '200 OK'
    resp.content_type = 'text/xml'
    resp.body = xml()
    return resp
264069
@Override
	public String[] toStringArray() {
		ArrayList<String> out = new ArrayList<>();
		out.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
		out.add("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");
		ArrayList<WebPage> values = new ArrayList<>(urls.values());
		Collections.sort(values);
		for (WebPage webPage : values) {
			out.add(constructUrl(webPage));
		}
		out.add("</sitemapindex>");
		return out.toArray(new String[] {});
	}
711432
protected function createSitemapPage()
    {
        $ret = '<?xml version="1.0" encoding="UTF-8"?>';
        $ret .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
        $ret .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
        $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9';
        $ret .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';

        $pagePriorityDefaultValue     = (float)GeneralUtility::getRootSettingValue('sitemap_priority', 0);
        $pagePriorityDepthMultiplier  = (float)GeneralUtility::getRootSettingValue(
            'sitemap_priority_depth_multiplier',
            0
        );
        $pagePriorityDepthModificator = (float)GeneralUtility::getRootSettingValue(
            'sitemap_priority_depth_modificator',
            0
        );

        if ($pagePriorityDefaultValue == 0) {
            $pagePriorityDefaultValue = 1;
        }

        if ($pagePriorityDepthMultiplier == 0) {
            $pagePriorityDepthMultiplier = 1;
        }

        if ($pagePriorityDepthModificator == 0) {
            $pagePriorityDepthModificator = 1;
        }


        // #####################
        // SetupTS conf
        // #####################

        foreach ($this->sitemapPages as $sitemapPage) {
            if (empty($this->pages[$sitemapPage['page_uid']])) {
                // invalid page
                continue;
            }

            $page = $this->pages[$sitemapPage['page_uid']];

            // #####################################
            // Page priority
            // #####################################
            $pageDepth     = $sitemapPage['page_depth'];
            $pageDepthBase = 1;

            if (!empty($sitemapPage['page_hash'])) {
                // page has module-content - trade as subpage
                ++$pageDepth;
            }

            $pageDepth -= $pagePriorityDepthModificator;


            if ($pageDepth > 0.1) {
                $pageDepthBase = 1 / $pageDepth;
            }

            $pagePriority = $pagePriorityDefaultValue * ($pageDepthBase * $pagePriorityDepthMultiplier);
            if (!empty($page['tx_metaseo_priority'])) {
                $pagePriority = $page['tx_metaseo_priority'] / 100;
            }

            $pagePriority = number_format($pagePriority, 2);

            if ($pagePriority > 1) {
                $pagePriority = '1.00';
            } elseif ($pagePriority <= 0) {
                $pagePriority = '0.00';
            }

            // #####################################
            // Page information
            // #####################################

            // page Url
            $pageUrl = GeneralUtility::fullUrl($sitemapPage['page_url']);

            // Page modification date
            $pageModificationDate = date('c', $sitemapPage['tstamp']);

            // Page change frequency
            $pageChangeFrequency = null;
            if (!empty($page['tx_metaseo_change_frequency'])) {
                // from page
                $pageChangeFrequency = (int)$page['tx_metaseo_change_frequency'];
            } elseif (!empty($sitemapPage['page_change_frequency'])) {
                // from sitemap settings
                $pageChangeFrequency = (int)$sitemapPage['page_change_frequency'];
            } elseif (!empty($this->tsSetup['changeFrequency'])) {
                // default from SetupTS
                $pageChangeFrequency = (int)$this->tsSetup['changeFrequency'];
            }

            // translate change frequency
            if (!empty($pageChangeFrequency) && !empty($this->pageChangeFrequency[$pageChangeFrequency])) {
                $pageChangeFrequency = $this->pageChangeFrequency[$pageChangeFrequency];
            } else {
                $pageChangeFrequency = null;
            }

            // #####################################
            // Sitemal page output
            // #####################################
            $ret .= '<url>';
            $ret .= '<loc>' . htmlspecialchars($pageUrl) . '</loc>';

            if ($this->tsSetup['enableLastMod']) {
                $ret .= '<lastmod>' . $pageModificationDate . '</lastmod>';
            }

            if (!empty($pageChangeFrequency)) {
                $ret .= '<changefreq>' . htmlspecialchars($pageChangeFrequency) . '</changefreq>';
            }

            if ($this->tsSetup['enablePriority']) {
                $ret .= '<priority>' . $pagePriority . '</priority>';
            }

            $ret .= '</url>';
        }


        $ret .= '</urlset>';

        // Call hook
        GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlPageOutput', $this, $ret);

        return $ret;
    }
822089
def to_s
      str = ''
      if @scheme
        str << @scheme
        str << ':'
      end

      if @opaque
        str << @opaque

      else
        if @registry
          str << @registry
        else
          if @host
            str << '//'
          end
          if self.userinfo
            str << self.userinfo
            str << '@'
          end
          if @host
            str << @host
          end
          if @port && @port != self.default_port
            str << ':'
            str << @port.to_s
          end
        end

        str << path_query
      end

      if @fragment
        str << '#'
        str << @fragment
      end

      str
    end