*aTag = NS_NewAtom(uri);
nsAutoString name; uri.Right(name, uri.Length()-1); *aTag = NS_NewAtom(name);
XULDocumentImpl::SplitProperty(nsIRDFResource* aProperty,                               PRInt32* aNameSpaceID,                               nsIAtom** aTag){    NS_PRECONDITION(aProperty != nsnull, "null ptr");    if (! aProperty)        return NS_ERROR_NULL_POINTER;    // XXX okay, this is a total hack. for this to work right, we need    // to either:    //    // 1) Remember what the namespace and the tag were when the    //    property was created, or    //    // 2) Iterate the entire set of namespace prefixes to see if the    //    specified property's URI has any of them as a substring.    //    const char* p;    aProperty->GetValue(&p);    nsAutoString uri(p);    PRInt32 index;    // First try to split the namespace using the rightmost '#' or '/'    // character.    if ((index = uri.RFind('#')) < 0) {        if ((index = uri.RFind('/')) < 0) {            *aNameSpaceID = kNameSpaceID_None;            *aTag = NS_NewAtom(uri);            return NS_OK;        }    }    // Using the above info, split the property's URI into a namespace    // prefix (that includes the trailing '#' or '/' character) and a    // tag.    nsAutoString tag;    PRInt32 count = uri.Length() - (index + 1);    uri.Right(tag, count);    uri.Cut(index + 1, count);    // XXX XUL atoms seem to all be in lower case. HTML atoms are in    // upper case. This sucks.    //tag.ToUpperCase();  // All XML is case sensitive even HTML in XML     nsresult rv;    PRInt32 nameSpaceID;    rv = mNameSpaceManager->GetNameSpaceID(uri, nameSpaceID);    // Did we find one?    if (NS_SUCCEEDED(rv) && nameSpaceID != kNameSpaceID_Unknown) {        *aNameSpaceID = nameSpaceID;        *aTag = NS_NewAtom(tag);        return NS_OK;    }    // Nope: so we'll need to be a bit more creative. Let's see    // what happens if we remove the rightmost '#' and then try...    if (uri.Last() == '#') {        uri.Truncate(uri.Length() - 1);        rv = mNameSpaceManager->GetNameSpaceID(uri, nameSpaceID);        if (NS_SUCCEEDED(rv) && nameSpaceID != kNameSpaceID_Unknown) {            *aNameSpaceID = nameSpaceID;            *aTag = NS_NewAtom(tag);            return NS_OK;        }    }    // allright, if we at least have a tag, then we can return the    // thing with kNameSpaceID_None for now.    if (tag.Length()) {        *aNameSpaceID = kNameSpaceID_None;        *aTag = NS_NewAtom(tag);        return NS_OK;    }    // Okay, somebody make this code even more convoluted.    NS_ERROR("unable to convert URI to namespace/tag pair");    return NS_ERROR_FAILURE; // XXX?}