case kNameSpaceID_XMLNS:
RDFXULBuilderImpl::AddAttribute(nsIContent* aElement,                                nsIRDFResource* aProperty,                                nsIRDFNode* aValue){    nsresult rv;    // First, split the property into its namespace and tag components    PRInt32 nameSpaceID;    nsCOMPtr<nsIAtom> tag;    if (NS_FAILED(rv = mDocument->SplitProperty(aProperty, &nameSpaceID, getter_AddRefs(tag)))) {        NS_ERROR("unable to split resource into namespace/tag pair");        return rv;    }    if ((nameSpaceID == kNameSpaceID_XMLNS) ||        ((nameSpaceID == kNameSpaceID_None) && (tag.get() == kXMLNSAtom))) {        // This is the receiving end of the namespace hack. The XUL        // content sink will dump "xmlns:" attributes into the graph        // so we can suck them out _here_ to install the proper        // namespace hierarchy (which we need to be able to create the        // illusion of the DOM).        //        // We pull the current containing namespace out of the        // element, use it to construct a new child namespace, then        // re-set the element's containing namespace to the new child        // namespace.        nsCOMPtr<nsIXMLContent> xml( do_QueryInterface(aElement) );        NS_ASSERTION(xml != nsnull, "not an XML element");        if (! xml)            return NS_ERROR_UNEXPECTED;        nsCOMPtr<nsINameSpace> parentNameSpace;        rv = xml->GetContainingNameSpace(*getter_AddRefs(parentNameSpace));        if (NS_FAILED(rv)) return rv;        NS_ASSERTION(parentNameSpace != nsnull, "no containing namespace");        if (! parentNameSpace)            return NS_ERROR_UNEXPECTED;        // the prefix is null for a default namespace        nsIAtom* prefix = (tag.get() != kXMLNSAtom) ? tag.get() : nsnull;        nsCOMPtr<nsIRDFLiteral> uri;        rv = aValue->QueryInterface(nsIRDFLiteral::GetIID(), getter_AddRefs(uri));        NS_ASSERTION(NS_SUCCEEDED(rv), "namespace URI not a literal");        if (NS_FAILED(rv)) return rv;        nsXPIDLString uriStr;        rv = uri->GetValue(getter_Copies(uriStr));        if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsINameSpace> childNameSpace;        rv = parentNameSpace->CreateChildNameSpace(prefix, (const PRUnichar*) uriStr,                                                   *getter_AddRefs(childNameSpace));        if (NS_FAILED(rv)) return rv;        rv = xml->SetContainingNameSpace(childNameSpace);        if (NS_FAILED(rv)) return rv;        return NS_OK;    }    if (IsHTMLElement(aElement)) {        // XXX HTML elements are picky and only want attributes from        // certain namespaces.        switch (nameSpaceID) {        case kNameSpaceID_HTML:        case kNameSpaceID_None:        case kNameSpaceID_Unknown:            break;        default:            PR_LOG(gLog, PR_LOG_ALWAYS,                   ("ignoring non-HTML attribute on HTML tag"));            return NS_OK;        }    }    nsCOMPtr<nsIRDFResource> resource;    nsCOMPtr<nsIRDFLiteral> literal;    // Now we need to figure out the attributes value and actually set    // it on the element. What we do differs a bit depending on    // whether we're aValue is a resource or a literal.    if (NS_SUCCEEDED(rv = aValue->QueryInterface(kIRDFResourceIID,                                                 (void**) getter_AddRefs(resource)))) {        nsXPIDLCString uri;        resource->GetValue( getter_Copies(uri) );        rv = aElement->SetAttribute(nameSpaceID, tag, (const char*) uri, PR_TRUE);    }    else if (NS_SUCCEEDED(rv = aValue->QueryInterface(kIRDFLiteralIID,                                                      (void**) getter_AddRefs(literal)))) {        nsXPIDLString s;        literal->GetValue( getter_Copies(s) );        rv = aElement->SetAttribute(nameSpaceID, tag, (const PRUnichar*) s, PR_TRUE);    }    else {        // This should _never_ happen.        NS_ERROR("uh, this isn't a resource or a literal!");        rv = NS_ERROR_UNEXPECTED;    }    return rv;}