/**
     *  Renders and prints sitemap XML.
     *  For gzip compression add paramter "compression" with compression method "bzip" or "gzip" as value.
     *  Appending a name paramter with a file name will name your download file if you request via browser.
     *  @access     public
     *  @return     void
     *  @todo       Create zend route from ./sitemap.xml to site/sitemap
     *  @todo       Create zend route from ./sitemap.xml.gz to site/sitemap/compression/gzip/name/sitemap.xml.gz
     *  @todo       Create zend route from ./sitemap.xml.bz2 to site/sitemap/compression/bzip/name/sitemap.xml.bz2
     *  @todo       add support for sitemap index
     */
    public function sitemapAction()
    {
        $compression = $this->getParam('compression');
        #        $page   = (integer) $this->getParam( 'page' );
        $pathGenerator = __DIR__ . '/libraries/SitemapGenerator/classes/';
        require_once $pathGenerator . 'Sitemap.php';
        require_once $pathGenerator . 'Sitemap/URL.php';
        require_once $pathGenerator . 'XML/Builder.php';
        require_once $pathGenerator . 'XML/Node.php';
        // Here we start the object cache id
        $sitemapObjectCacheIdSource = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        $sitemapObjectCacheId = 'sitemap_' . md5($sitemapObjectCacheIdSource);
        // try to load the cached value
        $erfurtObjectCache = OntoWiki::getInstance()->erfurt->getCache();
        $erfurtQueryCache = OntoWiki::getInstance()->erfurt->getQueryCache();
        $sitemapXml = $erfurtObjectCache->load($sitemapObjectCacheId);
        if ($sitemapXml === false) {
            $erfurtQueryCache->startTransaction($sitemapObjectCacheId);
            $siteConfig = $this->_getSiteConfig();
            $this->_loadModel();
            $query = '
SELECT DISTINCT ?resourceUri ?modified
WHERE { 
?resourceUri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type. 
OPTIONAL {?resourceUri <http://purl.org/dc/terms/modified> ?modified }
FILTER strstarts(str(?resourceUri), "' . $siteConfig['model'] . '") 
} ';
            //OPTIONAL {?resourceUri <http://purl.org/dc/terms/modified> ?modified }
            //?resourceUri <http://purl.org/dc/terms/modified> ?modified
            $results = $this->_model->sparqlQuery($query);
            $sitemap = new Sitemap();
            foreach ($results as $result) {
                $url = new Sitemap_URL($result['resourceUri']);
                if (isset($result['modified']) && strlen($result['modified'])) {
                    $url->setDatetime($result['modified']);
                }
                $sitemap->addUrl($url);
            }
            $sitemapXml = $sitemap->render();
            // save the page body as an object value for the object cache
            $erfurtObjectCache->save($sitemapXml, $sitemapObjectCacheId);
            // close the object cache transaction
            $erfurtQueryCache->endTransaction($sitemapObjectCacheId);
        }
        $contentType = "application/xml";
        // compression has been requested
        if (strlen(trim($compression))) {
            switch (strtolower($compression)) {
                case 'bzip':
                    $sitemapXml = bzcompress($sitemapXml);
                    $contentType = "application/x-bzip";
                    header('Content-Encoding: bzip2');
                    break;
                case 'gzip':
                    $sitemapXml = gzencode($sitemapXml);
                    $contentType = "application/x-gzip";
                    header('Content-Encoding: gzip');
                    break;
            }
        }
        header('Content-Length: ' . strlen($sitemapXml));
        header("Content-Type: " . $contentType);
        print $sitemapXml;
        exit;
    }