<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->

<!--

  This is a quick-and-dirty example that shows how you can mix
  ``static'' content with ``generated'' content.

-->

<?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">

  <tree datasources="buddy.rdf" ref="urn:root" flex="1*" sortStaticsLast="true">
    <template>
      <!-- This rule selects the buddy groups -->
      <rule>
        <conditions>
          <content uri="?uri" />
          <member container="?uri" child="?child" />
          <triple subject="?child" predicate="http://home.netscape.com/NC-rdf#type" object="buddy-group" />
        </conditions>

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

        <action>
          <treechildren>
            <treeitem uri="?child">
              <treerow>
                <treecell class="treecell-indent" label="?name" />
              </treerow>
            </treeitem>
          </treechildren>
        </action>
      </rule>

      <!-- This rule selects the individual buddies -->
      <rule>
        <conditions>
          <content uri="?uri" />
          <member container="?uri" child="?child" />
          <triple subject="?child" predicate="http://home.netscape.com/NC-rdf#status" object="online" />
        </conditions>

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

        <action>
          <treechildren>
            <treeitem uri="?child">
              <treerow>
                <treecell class="treecell-indent" label="?name" />
              </treerow>
            </treeitem>
          </treechildren>
        </action>
      </rule>
    </template>

    <treechildren flex="1">
      <!-- An explicit kid for the offline buddies -->
      <treeitem datasources="buddy.rdf" ref="urn:root" container="true">
        <treerow>
          <treecell flex="1" class="treecell-indent" label="Offline" />
        </treerow>

        <treechildren flex="1" />

        <!--

          XXX This is a bit kooky (a bug, really). You have to put the
          <template> element _last_ when it's contained within a
          <treeitem> because the tree code is hard-wired to look for
          children in specific locations.

        -->

        <template>
          <!-- This rule selects the buddy groups -->
          <rule>
            <conditions>
              <content uri="?uri" />
              <member container="?uri" child="?child" />
              <triple subject="?child" predicate="http://home.netscape.com/NC-rdf#type" object="buddy-group" />
            </conditions>

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

            <action>
              <treechildren>
                <treeitem uri="?child">
                  <treerow>
                    <treecell class="treecell-indent" label="?name" />
                  </treerow>
                </treeitem>
              </treechildren>
            </action>
          </rule>

          <!-- This rule selects the individual buddies -->
          <rule>
            <conditions>
              <content uri="?uri" />
              <member container="?uri" child="?child" />
              <triple subject="?child" predicate="http://home.netscape.com/NC-rdf#status" object="offline" />
            </conditions>

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

            <action>
              <treechildren>
                <treeitem uri="?child">
                  <treerow>
                    <treecell class="treecell-indent" label="?name" />
                  </treerow>
                </treeitem>
              </treechildren>
            </action>
          </rule>
        </template>

      </treeitem>
    </treechildren>

    <treecolgroup>
      <treecol flex="1*" />
    </treecolgroup>
  </tree>
</window>

