if (!PL_strcmp(sublistPtr->item, "*")) {
if (sublistPtr->item.Equals(NS_LITERAL_STRING("*"))) {
wallet_ResolveStateSchema(nsIDOMNode* elementNode, nsACString& schema) {  /* return if no StateSchema list exists */  if (!wallet_StateSchema_list) {    return;  }  /* search state schema list for our state schema */  wallet_MapElement * mapElementPtr;  PRInt32 count = LIST_COUNT(wallet_StateSchema_list);  for (PRInt32 i=0; i<count; i++) {    mapElementPtr = NS_STATIC_CAST(wallet_MapElement*, wallet_StateSchema_list->ElementAt(i));    if (schema.Equals(mapElementPtr->item1, nsCaseInsensitiveCStringComparator())) {      /* found our state schema in the list */      /* A state-schema entry consists of a set of possible states and the schema associated       * with each state.  For example, for the state-schema $phone we might have       *       *    ship  ShipTo.Phone       *    bill  BillTo.Phone       *    *     Home.Phone       *       * This means that if we are in the "ship" state, the schema is ShipTo.Phone, if in the       * "bill" state it is BillTo.Phone, and if in no identifiable state it is Home.Phone.       *       * So we will start stepping backwards through the dom tree       * obtaining text at each step.  If the text contains a substring for one of       * the states, then that is the state we are in and we take the associated       * schema.  If the text does not contain any of the states, we continue       * stepping back until we get to a preceding node for which we knew the state.       * If none is found, stop when we get to the beginning of the tree.       */      nsIDOMNode* localElementNode = elementNode;      PRBool atEnd = PR_FALSE;      PRBool atInputOrSelect = PR_FALSE;      while (!atEnd) {        /* get next text in the dom */        nsAutoString text;        wallet_StepForwardOrBack(localElementNode, text, atInputOrSelect, atEnd, PR_FALSE);        /* see if it's a node we already saved the state for */        if (localElementNode == previousElementNode) {          previousElementNode = elementNode;          /* step through the list of states to see if any are the state of the previous Node */          wallet_Sublist * sublistPtr;          PRInt32 count2 = LIST_COUNT(mapElementPtr->itemList);          PRInt32 j;          for (j=0; j<count2; j=j+2) {            sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j));            if (!PL_strcasecmp(sublistPtr->item, previousElementState)) {              previousElementState = sublistPtr->item;              sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1));              schema.Assign(sublistPtr->item);              return;            }            /* test to see if we obtained the catch-all (*) state.             *   Note: the catch-all must be the last entry in the list             */            if (!PL_strcmp(sublistPtr->item, "*")) {              sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1));              schema.Assign(sublistPtr->item);              return;            }          }          /* no catch-all state specified, return no schema */          return;        }        /* step through the list of states to see if any are in the text */        wallet_Sublist * sublistPtr;        PRInt32 count2 = LIST_COUNT(mapElementPtr->itemList);        for (PRInt32 j=0; j<count2; j=j+2) {          sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j));          /* next state obtained, test to see if it is in the text */          if (text.Find(sublistPtr->item, PR_TRUE) != -1) {            previousElementState = sublistPtr->item;            previousElementNode = elementNode;            sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1));            schema.Assign(sublistPtr->item);            return;          }        }      }      /* state not found, so take the catch-all (*) state */      wallet_Sublist * sublistPtr;      PRInt32 count2 = LIST_COUNT(mapElementPtr->itemList);      for (PRInt32 j=0; j<count2; j=j+2) {        sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j));        if (!PL_strcmp(sublistPtr->item, "*")) {          previousElementNode = localElementNode;          sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(j+1));          schema.Assign(sublistPtr->item);          previousElementNode = elementNode;          return;        }      }      /* no catch-all state specified, return no schema */      previousElementNode = elementNode;      return;    }  }  /* This is an error.  It means that a state-schema (entry starting with a $)   * was obtained from the SchemaStrings table or the PositionalSchema table   * but there was no entry for that state-schema in the StateSchema table.   */  NS_ASSERTION(PR_FALSE, "Undefined state in SchemaStrings table");}