return NS_RDF_ELEMENT_WAS_THERE;
return NS_OK;
RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResource* aResource, PRBool aNotify){    // Create the contents of a container by iterating over all of the    // "containment" arcs out of the element's resource.    nsresult rv;    // If it's XUL, then see if the item is even "open" (HTML content    // must be generated eagerly). If not, then just pretend it    // doesn't have _any_ contents. We check this _before_ checking    // the contents-generated attribute so that we don't eagerly set    // contents-generated on a closed node.    {        PRInt32 nameSpaceID;        rv = aElement->GetNameSpaceID(nameSpaceID);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get namespace ID");        if (NS_FAILED(rv)) return rv;        if (nameSpaceID == kNameSpaceID_XUL) {            if (! IsOpen(aElement))                return NS_OK;        }    }    // See if the element's templates contents have been generated:    // this prevents a re-entrant call from triggering another    // generation.    nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);    if (xulcontent) {        PRBool contentsGenerated;        rv = xulcontent->GetLazyState(nsIXULContent::eContainerContentsBuilt, contentsGenerated);        if (NS_FAILED(rv)) return rv;        if (contentsGenerated)            return NS_RDF_ELEMENT_WAS_THERE;        // Now mark the element's contents as being generated so that        // any re-entrant calls don't trigger an infinite recursion.        rv = xulcontent->SetLazyState(nsIXULContent::eContainerContentsBuilt);    }    else {        // HTML is always needs to be generated.        //        // XXX Big ass-umption here -- I am assuming that this will        // _only_ ever get called (in the case of an HTML element)        // when the XUL builder is descending thru the graph and        // stumbles on a template that is rooted at an HTML element.        // (/me crosses fingers...)    }    // XXX Eventually, we may want to factor this into one method that    // handles RDF containers (RDF:Bag, et al.) and another that    // handles multi-attributes. For performance...    // Create a cursor that'll enumerate all of the outbound arcs    nsCOMPtr<nsISimpleEnumerator> properties;    rv = mDB->ArcLabelsOut(aResource, getter_AddRefs(properties));    if (NS_FAILED(rv)) return rv;    while (1) {        PRBool hasMore;        rv = properties->HasMoreElements(&hasMore);        if (NS_FAILED(rv)) return rv;        if (! hasMore)            break;        nsCOMPtr<nsISupports> isupports;        rv = properties->GetNext(getter_AddRefs(isupports));        if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsIRDFResource> property = do_QueryInterface(isupports);        // If it's not a containment property, then it doesn't specify an        // object that is member of the current container element;        // rather, it specifies a "simple" property of the container        // element. Skip it.        if (!IsContainmentProperty(aElement, property))            continue;        // Create a second cursor that'll enumerate all of the values        // for all of the arcs.        nsCOMPtr<nsISimpleEnumerator> targets;        rv = mDB->GetTargets(aResource, property, PR_TRUE, getter_AddRefs(targets));        if (NS_FAILED(rv)) return rv;        while (1) {            PRBool hasMoreElements;            rv = targets->HasMoreElements(&hasMoreElements);            if (NS_FAILED(rv)) return rv;            if (! hasMoreElements)                break;            nsCOMPtr<nsISupports> isupportsNext;            rv = targets->GetNext(getter_AddRefs(isupportsNext));            if (NS_FAILED(rv)) return rv;            nsCOMPtr<nsIRDFResource> target = do_QueryInterface(isupportsNext);            NS_ASSERTION(target != nsnull, "not a resource");            if (! target)                continue;            rv = CreateWidgetItem(aElement, property, target, aNotify);            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create item");            if (NS_FAILED(rv)) return rv;        }    }    return NS_RDF_ELEMENT_GOT_CREATED;}