<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>

<window xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  align="vertical" onload="init();">

  <script language="JavaScript">
  // Grab the RDF service; we'll be needing it later.
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
    .getService(Components.interfaces.nsIRDFService);

  var vbox;
  var datasource;

  function init() {
    // After the XUL is loaded, load RDF/XML from the CGI script and
    // populate our template using that data.  This is called once,
    // from the XUL document's "onload" handler.
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    datasource = RDF.GetDataSource("http://www.maubi.net/~waterson/cgi-bin/spew.cgi");
    
    vbox = document.getElementById("vbox");
    vbox.database.AddDataSource(datasource);
  }

  function reload()
  {
    // Force the data to be reloaded from the CGI.  Called when the
    // user clicks the "Reload" button.
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Refresh(false);
  }
  </script>

  <vbox id="vbox" datasources="rdf:null" ref="urn:root">
    <template>
      <rule>
        <conditions>
          <content uri="?uri" />

          <triple subject="?uri"
                  predicate="http://home.netscape.com/NC-rdf#links"
                  object="?links" />

          <member container="?links" child="?child" />

          <triple subject="?child"
                  predicate="http://home.netscape.com/NC-rdf#name"
                  object="?name" />
        </conditions>

        <action>
          <hbox>
            <label uri="?child" value="?name" />
          </hbox>
        </action>
      </rule>
    </template>
  </vbox>
  <button label="Reload" onclick="reload();" />
</window>