*aRange = range.get();
*aRange = range;
static nsresult GetRange(                   nsIDOMDocument *aDocument,                   const nsAString& aExpression,                   nsIDOMRange **aRange){  nsresult rv = NS_OK;  nsCOMPtr<nsIDOMNode> node;  if (nsCRT::IsAsciiAlpha(aExpression.First())) {    // name    nsAutoString id;    const nsAutoString expression(aExpression);    PRInt32 sep = expression.FindCharInSet("/(");    if (sep > 0) {      expression.Left(id,sep);      nsCOMPtr<nsIDOMElement> element;      aDocument->GetElementById(id, getter_AddRefs(element));      node = do_QueryInterface(element);      if (node) {        if (expression[sep] == '/') {          // tumbler          nsAutoString tumbler;          expression.Mid(tumbler, sep, expression.Length());          sep = tumbler.FindChar('(');          if (sep > 0)            tumbler.Truncate(sep);          nsCOMPtr<nsIDOMNode> child;          GetTumblerNode(node, tumbler, getter_AddRefs(child));          node = child;        }        // char        sep = expression.FindChar('(');        if (sep > 0) {          nsAutoString charNum(aExpression);          if (charNum[charNum.Length() -1] == ')') {            charNum.Truncate(charNum.Length() - 1);            charNum.Cut(0, sep + 1);            PRInt32 error;            PRInt32 n = charNum.ToInteger(&error);            if (n < 1)              return NS_OK;            rv = GetCharRange(node, n - 1, aRange);            if (!*aRange) {              node = nsnull;            }          }        }      }    } else {      // just name      nsCOMPtr<nsIDOMElement> element;      aDocument->GetElementById(expression, getter_AddRefs(element));      node = do_QueryInterface(element);    }  } else if (aExpression.First() == '/') {    // Starts with tumbler    node = do_QueryInterface(aDocument);    nsCOMPtr<nsIDOMNode> child;    nsAutoString tumbler(aExpression);    PRInt32 sep = tumbler.FindChar('(');    if (sep > 0)      tumbler.Truncate(sep);    GetTumblerNode(node, tumbler, getter_AddRefs(child));    node = child;    // char    sep = aExpression.FindChar('(');    if (sep > 0) {      nsAutoString charNum(aExpression);      if (charNum[charNum.Length() -1] == ')') {        charNum.Truncate(charNum.Length() - 1);        charNum.Cut(0, sep + 1);        PRInt32 error;        PRInt32 n = charNum.ToInteger(&error);        if (n < 1)          return NS_OK;        rv = GetCharRange(node, n - 1, aRange);        if (!*aRange) {          node = nsnull;        }      }    }  } else {    // Not FIXptr  }  if (NS_SUCCEEDED(rv) && !*aRange && node) {    nsCOMPtr<nsIDOMRange> range(do_CreateInstance(kRangeCID));      if (!range)      return NS_ERROR_OUT_OF_MEMORY;    range->SelectNode(node);    *aRange = range.get();    NS_ADDREF(*aRange);  }  return rv;}