SetEmpty(content, *bestmatch);
nsXULTemplateBuilder::FireNewlyMatchedRules(const KeySet& aNewKeys){    // Iterate through newly added keys to determine which rules fired.    //    // XXXwaterson Unfortunately, this could also lead to retractions;    // e.g., (contaner ?a ^empty false) could become "unmatched". How    // to track those?    nsresult rv;    KeySet::ConstIterator last = aNewKeys.Last();    for (KeySet::ConstIterator key = aNewKeys.First(); key != last; ++key) {        const MatchSet* matches;        mConflictSet.GetMatches(*key, &matches);        NS_ASSERTION(matches != nsnull, "no matched rules for new key");        if (! matches)            continue;        const Match* bestmatch =            matches->FindMatchWithHighestPriority();        NS_ASSERTION(bestmatch != nsnull, "no matches in match set");        if (! bestmatch)            continue;        // XXXwaterson fix me!        const Match& lastmatch = matches->GetLastMatch();        if (*bestmatch != lastmatch) {            Value value;            nsIContent* content;            PRBool hasbinding;            do {                // See if we need to yank anything out of the content                // model to handle the newly matched rule. If the                // instantiation has a binding for the content                // variable, there's content that's been built that we                // need to pull.                hasbinding = lastmatch.mInstantiation.mBindings.GetBindingFor(mContentVar, &value);                if (! hasbinding) break;                nsIContent* parent = VALUE_TO_ICONTENT(value);                PRInt32 membervar = lastmatch.mRule->GetMemberVariable();                hasbinding = lastmatch.mInstantiation.mBindings.GetBindingFor(membervar, &value);                nsIRDFResource* member = VALUE_TO_IRDFRESOURCE(value);                RemoveMember(parent, member, PR_TRUE);            } while (0);            // Get the content node to which we were bound            hasbinding = bestmatch->mInstantiation.mBindings.GetBindingFor(mContentVar, &value);            NS_ASSERTION(hasbinding, "no content binding");            if (! hasbinding)                continue;            content = VALUE_TO_ICONTENT(value);            nsCOMPtr<nsIContent> tmpl;            bestmatch->mRule->GetContent(getter_AddRefs(tmpl));            rv = BuildContentFromTemplate(tmpl, content, content, PR_TRUE,                                          VALUE_TO_IRDFRESOURCE(key->mMemberValue),                                          PR_TRUE, *bestmatch, nsnull, nsnull);            if (NS_FAILED(rv)) return rv;        }    }    return NS_OK;}