PRInt32 nameSpaceID; nsCOMPtr<nsIAtom> tag; rv = mDocument->SplitProperty(aProperty, &nameSpaceID, getter_AddRefs(tag));
PRInt32	numAttribs; rv = aTemplateNode->GetAttributeCount(numAttribs);
RDFGenericBuilderImpl::SynchronizeUsingTemplate(nsIContent* aTemplateNode,                                                nsIContent* aTreeItemElement,                                                eUpdateAction aAction,                                                nsIRDFResource* aProperty,                                                nsIRDFNode* aValue){	nsresult rv;	PRInt32 nameSpaceID;	nsCOMPtr<nsIAtom> tag;	rv = mDocument->SplitProperty(aProperty, &nameSpaceID, getter_AddRefs(tag));	if (NS_FAILED(rv)) return rv;	// check all attributes on the template node; if they reference a resource,	// update the equivalent attribute on the content node    //    // XXX This is bizarre. Why don't we just use the property to    // figure out which attribute to ask for, and then ask for the    // attribute and update it???    //	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 = nsRDFContentUtils::GetTextForNode(aValue, text);                if (NS_FAILED(rv)) return rv;                if ((text.Length() > 0) && (aAction == eSet)) {                    aTreeItemElement->SetAttribute(attribNameSpaceID,                                                   attribName,                                                   text,                                                   PR_TRUE);                }                else {                    aTreeItemElement->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    nsAutoString contentsGenerated;    rv = aTreeItemElement->GetAttribute(kNameSpaceID_None,                                        kTemplateContentsGeneratedAtom,                                        contentsGenerated);    if (NS_FAILED(rv)) return rv;    if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (contentsGenerated.EqualsIgnoreCase("true"))) {        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 = aTreeItemElement->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;}