nsCOMPtr<nsIURI> url = dont_AddRef( doc->GetDocumentURL() );
nsCOMPtr<nsIURI> url; doc->GetDocumentURL(getter_AddRefs(url));
nsXULContentUtils::GetElementRefResource(nsIContent* aElement, nsIRDFResource** aResult){    // Perform a reverse mapping from an element in the content model    // to an RDF resource. Check for a "ref" attribute first, then    // fallback on an "id" attribute.    nsresult rv;    PRUnichar buf[128];    nsAutoString uri(CBufDescriptor(buf, PR_TRUE, sizeof(buf) / sizeof(PRUnichar), 0));    rv = aElement->GetAttribute(kNameSpaceID_None, nsXULAtoms::ref, uri);    NS_ASSERTION(NS_SUCCEEDED(rv), "severe error retrieving attribute");    if (NS_FAILED(rv)) return rv;    if (rv == NS_CONTENT_ATTR_HAS_VALUE) {        // We'll use rdf_MakeAbsolute() to translate this to a URL.        nsCOMPtr<nsIDocument> doc;        rv = aElement->GetDocument(*getter_AddRefs(doc));        if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsIURI> url = dont_AddRef( doc->GetDocumentURL() );        NS_ASSERTION(url != nsnull, "element has no document");        if (! url)            return NS_ERROR_UNEXPECTED;    		nsCAutoString uriStr;        uriStr.Assign(NS_ConvertUCS2toUTF8(uri));        rv = rdf_MakeAbsoluteURI(url, uriStr);        if (NS_FAILED(rv)) return rv;        rv = gRDF->GetResource(uriStr.GetBuffer(), aResult);    }    else {        rv = GetElementResource(aElement, aResult);    }    return rv;}