attrs->mValue       = id;
attrs->mValue.SetValue( id );
XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElement* aElement){    // Add tag attributes to the element    nsresult rv;    PRInt32 count = aNode.GetAttributeCount();    PRBool generateIDAttr = PR_FALSE;    if (mContextStack.IsInsideXULTemplate()) {        // Check for an 'id' attribute.  If we're inside a XUL        // template, then _everything_ needs to have an ID for the        // 'template' attribute hookup.        generateIDAttr = PR_TRUE;        for (PRInt32 i = 0; i < count; i++) {            if (aNode.GetKeyAt(i).EqualsWithConversion("id")) {                generateIDAttr = PR_FALSE;                break;            }        }    }    // Create storage for the attributes    PRInt32 numattrs = count;    if (generateIDAttr)        ++numattrs;    nsXULPrototypeAttribute* attrs = nsnull;    if (numattrs > 0) {      attrs = new nsXULPrototypeAttribute[numattrs];      if (! attrs)        return NS_ERROR_OUT_OF_MEMORY;    }    aElement->mAttributes    = attrs;    aElement->mNumAttributes = numattrs;    if (generateIDAttr) {        // Deal with generating an ID attribute for stuff inside a XUL        // template        nsAutoString id; id.AssignWithConversion("$");        id.AppendInt(PRInt32(aElement), 16);        mNodeInfoManager->GetNodeInfo(kIdAtom, nsnull, kNameSpaceID_None,                                      *getter_AddRefs(attrs->mNodeInfo));        NS_ENSURE_TRUE(attrs->mNodeInfo, NS_ERROR_FAILURE);        attrs->mValue       = id;        ++attrs;    }    // Copy the attributes into the prototype    for (PRInt32 i = 0; i < count; i++) {        const nsString& qname = aNode.GetKeyAt(i);        rv = NormalizeAttributeString(qname,                                      *getter_AddRefs(attrs->mNodeInfo));        if (NS_FAILED(rv)) {            nsCAutoString qnameC;            qnameC.AssignWithConversion(qname);            PR_LOG(gLog, PR_LOG_ALWAYS,                   ("xul: unable to parse attribute '%s' at line %d",                    (const char*) qnameC, aNode.GetSourceLineNumber()));            // Bring it. We'll just fail to copy an attribute that we            // can't parse. And that's one less attribute to worry            // about.            --(aElement->mNumAttributes);            continue;        }        attrs->mValue       = aNode.GetValueAt(i);        nsRDFParserUtils::StripAndConvert(attrs->mValue);#ifdef PR_LOGGING        if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {            nsCAutoString extraWhiteSpace;            PRInt32 cnt = mContextStack.Depth();            while (--cnt >= 0)                extraWhiteSpace += "  ";            nsCAutoString qnameC,valueC;            qnameC.AssignWithConversion(qname);            valueC.AssignWithConversion(attrs->mValue);            PR_LOG(gLog, PR_LOG_DEBUG,                   ("xul: %.5d. %s    %s=%s",                    aNode.GetSourceLineNumber(),                    NS_STATIC_CAST(const char*, extraWhiteSpace),                    NS_STATIC_CAST(const char*, qnameC),                    NS_STATIC_CAST(const char*, valueC)));        }#endif        ++attrs;    }    // XUL elements may require some additional work to compute    // derived information.    if (aElement->mNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {        nsAutoString value;        // Compute the element's class list if the element has a 'class' attribute.        rv = aElement->GetAttribute(kNameSpaceID_None, kClassAtom, value);        if (NS_FAILED(rv)) return rv;        if (rv == NS_CONTENT_ATTR_HAS_VALUE) {            rv = nsClassList::ParseClasses(&aElement->mClassList, value);            if (NS_FAILED(rv)) return rv;        }        // Parse the element's 'style' attribute        rv = aElement->GetAttribute(kNameSpaceID_None, kStyleAtom, value);        if (NS_FAILED(rv)) return rv;        if (rv == NS_CONTENT_ATTR_HAS_VALUE) {            if (! mCSSParser) {                rv = nsComponentManager::CreateInstance(kCSSParserCID,                                                        nsnull,                                                        NS_GET_IID(nsICSSParser),                                                        getter_AddRefs(mCSSParser));                if (NS_FAILED(rv)) return rv;            }            rv = mCSSParser->ParseDeclarations(value,                                               mDocumentURL,                                               *getter_AddRefs(aElement->mInlineStyleRule));            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse style rule");            if (NS_FAILED(rv)) return rv;        }    }    return NS_OK;}