if ((aProperty == kRDF_nextVal) || (aProperty == kRDF_instanceOf))
if (aProperty == kRDF_nextVal)
RDFXULBuilderImpl::OnAssert(nsIRDFResource* aSource,                            nsIRDFResource* aProperty,                            nsIRDFNode* aTarget){    NS_PRECONDITION(mDocument != nsnull, "not initialized");    if (! mDocument)        return NS_ERROR_NOT_INITIALIZED;    // Stuff that we can ignore outright    // XXX is this the best place to put it???    if ((aProperty == kRDF_nextVal) ||        (aProperty == kRDF_instanceOf))        return NS_OK;    nsresult rv;    {        // Make sure it's a XUL node we're talking about        PRBool isXULElement;        rv = mDB->HasAssertion(aSource, kRDF_instanceOf, kXUL_element, PR_TRUE, &isXULElement);        if (NS_FAILED(rv)) return rv;        if (! isXULElement)            return NS_OK;    }    nsCOMPtr<nsISupportsArray> elements;    if (NS_FAILED(rv = NS_NewISupportsArray(getter_AddRefs(elements)))) {        NS_ERROR("unable to create new ISupportsArray");        return rv;    }    // Find all the elements in the content model that correspond to    // aSource: for each, we'll try to build XUL children if    // appropriate.    if (NS_FAILED(rv = mDocument->GetElementsForResource(aSource, elements))) {        NS_ERROR("unable to retrieve elements from resource");        return rv;    }    for (PRInt32 i = elements->Count() - 1; i >= 0; --i) {        nsCOMPtr<nsIContent> element( do_QueryInterface(elements->ElementAt(i)) );        // Make sure that the element we're looking at is really an        // element generated by the XUL content-model builder.        nsAutoString instanceOf;        if (NS_CONTENT_ATTR_HAS_VALUE !=            element->GetAttribute(kNameSpaceID_RDF,                                  kInstanceOfAtom,                                  instanceOf))            continue;        if (! instanceOf.Equals(kURIXUL_element))            continue;                if (rdf_IsOrdinalProperty(aProperty)) {            // It's a child node. If the contents of aElement _haven't_            // yet been generated, then just ignore the assertion. We do            // this because we know that _eventually_ the contents will be            // generated (via CreateContents()) when somebody asks for            // them later.            nsAutoString contentsGenerated;            if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None,                                                     kXULContentsGeneratedAtom,                                                     contentsGenerated))) {                NS_ERROR("severe problem trying to get attribute");                return rv;            }            if (rv == NS_CONTENT_ATTR_NOT_THERE || rv == NS_CONTENT_ATTR_NO_VALUE)                continue;            if (! contentsGenerated.EqualsIgnoreCase("true"))                continue;            // Okay, it's a "live" element, so go ahead and append the new            // child to this node.            nsCOMPtr<nsINameSpace> containingNameSpace;            rv = GetContainingNameSpace(element, getter_AddRefs(containingNameSpace));            if (NS_FAILED(rv)) return rv;            rv = AppendChild(containingNameSpace, element, aTarget);            NS_ASSERTION(NS_SUCCEEDED(rv), "problem appending child to content model");            if (NS_FAILED(rv)) return rv;        }        else if (aProperty == kRDF_type) {            // We shouldn't ever see this: if we do, there ain't much we            // can do.            NS_ERROR("attempt to change tag type after-the-fact");            return NS_ERROR_UNEXPECTED;        }        else {            // Add the thing as a vanilla attribute to the element.            if (NS_FAILED(rv = AddAttribute(element, aProperty, aTarget))) {                NS_ERROR("unable to add attribute to the element");                return rv;            }        }    }    return NS_OK;}