if (property.get() == aProperty) {
nsXULTemplateBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,                                               nsIContent* aRealElement,                                               UpdateAction aAction,                                               nsIRDFResource* aProperty,                                               nsIRDFNode* aValue){    nsresult rv;    // check all attributes on the template node; if they reference a resource,    // update the equivalent attribute on the content node    PRInt32    numAttribs;    rv = aTemplateNode->GetAttributeCount(numAttribs);    if (NS_FAILED(rv)) return rv;    if (rv == NS_CONTENT_ATTR_HAS_VALUE) {        for (PRInt32 aLoop=0; aLoop<numAttribs; aLoop++) {            PRInt32    attribNameSpaceID;            nsCOMPtr<nsIAtom> attribName;            rv = aTemplateNode->GetAttributeNameAt(aLoop,                                                   attribNameSpaceID,                                                   *getter_AddRefs(attribName));            if (NS_FAILED(rv)) return rv;            nsAutoString attribValue;            rv = aTemplateNode->GetAttribute(attribNameSpaceID,                                             attribName,                                             attribValue);            if (NS_FAILED(rv)) return rv;            if (rv != NS_CONTENT_ATTR_HAS_VALUE)                continue;            if (attribValue.Find("rdf:") != 0)                continue;            // found an attribute which wants to bind its value            // to RDF so look it up in the graph            attribValue.Cut(0,4);            nsCOMPtr<nsIRDFResource> property;            rv = gRDFService->GetUnicodeResource(attribValue.GetUnicode(),                                                 getter_AddRefs(property));            if (NS_FAILED(rv)) return rv;            if (property.get() == aProperty) {                nsAutoString text;                rv = gXULUtils->GetTextForNode(aValue, text);                if (NS_FAILED(rv)) return rv;                if ((text.Length() > 0) && (aAction == eSet)) {                    aRealElement->SetAttribute(attribNameSpaceID,                                                   attribName,                                                   text,                                                   PR_TRUE);                }                else {                    aRealElement->UnsetAttribute(attribNameSpaceID,                                                     attribName,                                                     PR_TRUE);                }            }        }    }    // See if we've generated kids for this node yet. If we have, then    // recursively sync up template kids with content kids    PRBool contentsGenerated = PR_TRUE;    nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aRealElement);    if (xulcontent) {        rv = xulcontent->GetLazyState(nsIXULContent::eTemplateContentsBuilt,                                      contentsGenerated);        if (NS_FAILED(rv)) return rv;    }    else {        // HTML content will _always_ have been generated up-front    }    if (contentsGenerated) {        PRInt32 count;        rv = aTemplateNode->ChildCount(count);        if (NS_FAILED(rv)) return rv;        for (PRInt32 loop=0; loop<count; loop++) {            nsCOMPtr<nsIContent> tmplKid;            rv = aTemplateNode->ChildAt(loop, *getter_AddRefs(tmplKid));            if (NS_FAILED(rv)) return rv;            if (! tmplKid)                break;            nsCOMPtr<nsIContent> realKid;            rv = aRealElement->ChildAt(loop, *getter_AddRefs(realKid));            if (NS_FAILED(rv)) return rv;            if (! realKid)                break;            rv = SynchronizeUsingTemplate(tmplKid, realKid, aAction, aProperty, aValue);            if (NS_FAILED(rv)) return rv;        }    }    return NS_OK;}