nsXULContentUtils::FindChildByTag(aRuleElement, kNameSpaceID_XUL, nsXULAtoms::bindings, getter_AddRefs(bindings));
gXULUtils->FindChildByTag(aRuleElement, kNameSpaceID_XUL, nsXULAtoms::bindings, getter_AddRefs(bindings));
nsXULTemplateBuilder::CompileExtendedRule(nsIContent* aRuleElement,                                          PRInt32 aPriority,                                          InnerNode* aParentNode){    // Compile an "extended" <template> rule. An extended rule must    // have a <conditions> child, and an <action> child, and may    // optionally have a <bindings> child.    nsresult rv;    nsCOMPtr<nsIContent> conditions;    nsXULContentUtils::FindChildByTag(aRuleElement,                                      kNameSpaceID_XUL,                                      nsXULAtoms::conditions,                                      getter_AddRefs(conditions));    if (! conditions) {        PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,               ("xultemplate[%p] no <conditions> element in extended rule", this));        return NS_OK;    }    nsCOMPtr<nsIContent> action;    nsXULContentUtils::FindChildByTag(aRuleElement,                                      kNameSpaceID_XUL,                                      nsXULAtoms::action,                                      getter_AddRefs(action));    if (! action) {        PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,               ("xultemplate[%p] no <action> element in extended rule", this));        return NS_OK;    }    // If we've got <conditions> and <action>, we can make a rule.    nsTemplateRule* rule = new nsTemplateRule(mDB, action, aPriority);    if (! rule)        return NS_ERROR_OUT_OF_MEMORY;    rule->SetContainerVariable(mContainerVar);    if (! mMemberSymbol.Length()) {        // If the member variable hasn't already been specified, then        // grovel over <action> to find it. We'll use the first one        // that we find in a breadth-first search.        nsVoidArray unvisited;        unvisited.AppendElement(action.get());        while (unvisited.Count()) {            nsIContent* next = NS_STATIC_CAST(nsIContent*, unvisited[0]);            unvisited.RemoveElementAt(0);            nsAutoString uri;            next->GetAttribute(kNameSpaceID_None, nsXULAtoms::uri, uri);            if (!uri.IsEmpty() && uri[0] == PRUnichar('?')) {                // Found it.                mMemberSymbol = uri;                if (! mRules.LookupSymbol(mMemberSymbol.get()))                    mRules.PutSymbol(mMemberSymbol.get(), mMemberVar);                break;            }            // otherwise, append the children to the unvisited list: this            // results in a breadth-first search.            PRInt32 count;            next->ChildCount(count);            for (PRInt32 i = 0; i < count; ++i) {                nsCOMPtr<nsIContent> child;                next->ChildAt(i, *getter_AddRefs(child));                unvisited.AppendElement(child.get());            }        }    }    // If we can't find a member symbol, then we're out of luck. Bail.    if (! mMemberSymbol.Length()) {        PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,               ("xultemplate[%p] could not deduce member variable", this));        delete rule;        return NS_OK;    }    rule->SetMemberVariable(mMemberVar);    InnerNode* last;    rv = CompileConditions(rule, conditions, aParentNode, &last);    // If the rule compilation failed, or we don't have a container    // symbol, then we have to bail.    if (NS_FAILED(rv)) {        delete rule;        return rv;    }    if (!mContainerSymbol.Length()) {        PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,               ("xultemplate[%p] could not deduce container variable", this));        delete rule;        return NS_OK;    }    // And now add the instantiation node: it owns the rule now.    nsInstantiationNode* instnode =        new nsInstantiationNode(mConflictSet, rule, mDB);    if (! instnode) {        delete rule;        return NS_ERROR_OUT_OF_MEMORY;    }    last->AddChild(instnode);    mRules.AddNode(instnode);        // If we've got bindings, add 'em.    nsCOMPtr<nsIContent> bindings;    nsXULContentUtils::FindChildByTag(aRuleElement,                                      kNameSpaceID_XUL,                                      nsXULAtoms::bindings,                                      getter_AddRefs(bindings));    if (bindings) {        rv = CompileBindings(rule, bindings);        if (NS_FAILED(rv)) return rv;    }    return NS_OK;}