RDFContainerInstanceTestNode::Test isempty = RDFContainerInstanceTestNode::eDontCare;
nsRDFConInstanceTestNode::Test isempty = nsRDFConInstanceTestNode::eDontCare;
nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement,                                        PRInt32 aPriority,                                        InnerNode* aParentNode){    // Compile a "simple" (or old-school style) <template> rule.    nsresult rv;    PRBool hasContainerTest = PR_FALSE;    PRInt32 count;    aRuleElement->GetAttributeCount(count);    // Add constraints for the LHS    for (PRInt32 i = 0; i < count; ++i) {        PRInt32 attrNameSpaceID;        nsCOMPtr<nsIAtom> attr;        rv = aRuleElement->GetAttributeNameAt(i, attrNameSpaceID, *getter_AddRefs(attr));        if (NS_FAILED(rv)) return rv;        // Note: some attributes must be skipped on XUL template rule subtree        // never compare against rdf:property attribute        if ((attr.get() == nsXULAtoms::property) && (attrNameSpaceID == kNameSpaceID_RDF))            continue;        // never compare against rdf:instanceOf attribute        else if ((attr.get() == nsXULAtoms::instanceOf) && (attrNameSpaceID == kNameSpaceID_RDF))            continue;        // never compare against {}:id attribute        else if ((attr.get() == nsXULAtoms::id) && (attrNameSpaceID == kNameSpaceID_None))            continue;        // never compare against {}:xulcontentsgenerated attribute        else if ((attr.get() == nsXULAtoms::xulcontentsgenerated) && (attrNameSpaceID == kNameSpaceID_None))            continue;        nsAutoString value;        rv = aRuleElement->GetAttribute(attrNameSpaceID, attr, value);        if (NS_FAILED(rv)) return rv;        TestNode* testnode = nsnull;        if ((attrNameSpaceID == kNameSpaceID_None) && (attr.get() == nsXULAtoms::parent)) {            // The "parent" test.            //            // XXXwaterson this is wrong: we can't add this below the            // the previous node, because it'll cause an unconstrained            // search if we ever came "up" through this path. Need a            // JoinNode in here somewhere.            nsCOMPtr<nsIAtom> tag = dont_AddRef(NS_NewAtom(value));            testnode = new ContentTagTestNode(aParentNode, mConflictSet, mContentVar, tag);            if (! testnode)                return NS_ERROR_OUT_OF_MEMORY;        }        else if (((attrNameSpaceID == kNameSpaceID_None) && (attr.get() == nsXULAtoms::iscontainer)) ||                 ((attrNameSpaceID == kNameSpaceID_None) && (attr.get() == nsXULAtoms::isempty))) {            // Tests about containerhood and emptiness. These can be            // globbed together, mostly. Check to see if we've already            // added a container test: we only need one.            if (hasContainerTest)                continue;            RDFContainerInstanceTestNode::Test iscontainer =                RDFContainerInstanceTestNode::eDontCare;            rv = aRuleElement->GetAttribute(kNameSpaceID_None, nsXULAtoms::iscontainer, value);            if (NS_FAILED(rv)) return rv;            if (rv == NS_CONTENT_ATTR_HAS_VALUE) {                if (value.EqualsWithConversion("true")) {                    iscontainer = RDFContainerInstanceTestNode::eTrue;                }                else if (value.EqualsWithConversion("false")) {                    iscontainer = RDFContainerInstanceTestNode::eFalse;                }            }            RDFContainerInstanceTestNode::Test isempty =                RDFContainerInstanceTestNode::eDontCare;            rv = aRuleElement->GetAttribute(kNameSpaceID_None, nsXULAtoms::isempty, value);            if (NS_FAILED(rv)) return rv;            if (rv == NS_CONTENT_ATTR_HAS_VALUE) {                if (value.EqualsWithConversion("true")) {                    isempty = RDFContainerInstanceTestNode::eTrue;                }                else if (value.EqualsWithConversion("false")) {                    isempty = RDFContainerInstanceTestNode::eFalse;                }            }            testnode = new RDFContainerInstanceTestNode(aParentNode,                                                        mConflictSet,                                                        mDB,                                                        mContainmentProperties,                                                        mMemberVar,                                                        iscontainer,                                                        isempty);            if (! testnode)                return NS_ERROR_OUT_OF_MEMORY;            mRDFTests.Add(testnode);        }        else {            // It's a simple RDF test            nsCOMPtr<nsIRDFResource> property;            rv = gXULUtils->GetResource(attrNameSpaceID, attr, getter_AddRefs(property));            if (NS_FAILED(rv)) return rv;            // XXXwaterson this is so manky            nsCOMPtr<nsIRDFNode> target;            if (value.FindChar(':') != -1) { // XXXwaterson WRONG WRONG WRONG!                nsCOMPtr<nsIRDFResource> resource;                rv = gRDFService->GetUnicodeResource(value.GetUnicode(), getter_AddRefs(resource));                if (NS_FAILED(rv)) return rv;                target = do_QueryInterface(resource);            }            else {                nsCOMPtr<nsIRDFLiteral> literal;                rv = gRDFService->GetLiteral(value.GetUnicode(), getter_AddRefs(literal));                if (NS_FAILED(rv)) return rv;                target = do_QueryInterface(literal);            }            testnode = new RDFPropertyTestNode(aParentNode, mConflictSet, mDB, mMemberVar, property, target);            if (! testnode)                return NS_ERROR_OUT_OF_MEMORY;            mRDFTests.Add(testnode);        }        aParentNode->AddChild(testnode);        mRules.AddNode(testnode);        aParentNode = testnode;    }    // Create the rule.    Rule* rule = new Rule(mDB, aRuleElement, aPriority);    if (! rule)        return NS_ERROR_OUT_OF_MEMORY;    rule->SetContainerVariable(mContainerVar);    rule->SetMemberVariable(mMemberVar);    AddSimpleRuleBindings(rule, aRuleElement);    // The InstantiationNode owns the rule now.    InstantiationNode* instnode =        new InstantiationNode(mConflictSet, rule, mDB);    if (! instnode)        return NS_ERROR_OUT_OF_MEMORY;    aParentNode->AddChild(instnode);    mRules.AddNode(instnode);        return NS_OK;}