
var xsl = '/~cdent/mt/rss2html.xsl';
var warningMessage =
'<div class="rssfeed"> ' +
'<p>This trick has failed to work. It uses XSLTProcessor and XMLHTTPRequest ' +
'to alien URLs. ' +
'XSLTProcessor does not yet work in Safari. To get XMLHTTPRequest to ' +
'work with alien URLs in Mozilla or Firefox see: <a ' +
'href="http://www.mozilla.org/projects/security/components/jssec.html#codebase">codebase' +
' principals</a>. Please understand the implications if you choose to ' +
'enable it. I am unable to comment on IE at this time. See <a ' +
'href="/~cdent/mt/archives/000395.html#nidPNV">' +
'the announcement</a> for more info.</p>';

function fillDiv(element, url) {
    var fragment = rss2html(url, xsl);

    element = document.getElementById(element);
    if (fragment) {
        element.innerHTML = '';
        element.appendChild(fragment);
    } else {
        element.innerHTML = warningMessage +
'<p><a href="http://www.technorati.com/cosmos/search.html?rank=&amp;url=' +
escape(window.location) + '">Get Cosmos</a></p></div>';
    }
}

function rss2html(url, stylesheet) {
    var fragment;

    try {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        var xsltProcessor = new XSLTProcessor();
        var request = new XMLHttpRequest();

        request.open("GET", stylesheet, false);
        request.send(null);

        var xslRef = request.responseXML;
        
        xsltProcessor.importStylesheet(xslRef);

        request.open("GET", url, false);
        request.send(null);
        var rdf = request.responseXML;

        fragment = xsltProcessor.transformToFragment(rdf, document);
    } catch (exception) {
        //trap
    };
    return fragment;
}


