wallet_GetSchemaFromDisplayableText (nsIDOMNode* elementNode, nsACString& schema, PRBool skipStateChecking) {
wallet_GetSchemaFromDisplayableText(nsIDOMNode* elementNode, nsString& schema, PRBool skipStateChecking) {
wallet_GetSchemaFromDisplayableText    (nsIDOMNode* elementNode, nsACString& schema, PRBool skipStateChecking) {  static nsCString lastSchema;  static nsIDOMNode* lastElementNode;  /* return if this is the same as the last element node */  if (elementNode == lastElementNode) {    schema.Assign(lastSchema);    return;  }  lastElementNode = elementNode;  nsIDOMNode* localElementNode = elementNode;  PRBool atInputOrSelect = PR_FALSE;  PRBool atEnd = PR_FALSE;  PRBool someTextFound = PR_FALSE;  while (!atEnd && !atInputOrSelect) {    /* step back and get text found in a preceding node */    nsAutoString text;    wallet_StepForwardOrBack(localElementNode, text, atInputOrSelect, atEnd, PR_FALSE);    /* strip off non-alphanumerics */    PRUint32 i;    PRUnichar c;    nsAutoString temp;    for (i=0; i<text.Length(); i++) {      c = text.CharAt(i);      if (nsCRT::IsAsciiAlpha(c) || nsCRT::IsAsciiDigit(c)) {        temp.Append(c);      }    }    text = temp;    /* done if we've obtained enough text from which to determine the schema */    if (text.Length()) {      someTextFound = PR_TRUE;      TextToSchema(text, schema);      if (!schema.IsEmpty()) {        /* schema found, process positional schema if any */        if (!schema.IsEmpty() && schema.First() == '%') {          wallet_ResolvePositionalSchema(elementNode, schema);        }        /* process state schema if any */        if (!skipStateChecking && !schema.IsEmpty() && schema.First() == '$') {          wallet_ResolveStateSchema(elementNode, schema);         }        lastSchema.Assign(schema);        return;      }    }  }  /* no displayable text found, see if we are inside a position set */  if (!someTextFound) {    wallet_ResolvePositionalSchema(elementNode, schema);  }  /* process state schema if any */  /* The current routine is called for each field whose value is to be captured,   * even if there is no value entered for that field.  We do this because we need   * to call ResolvePositionalSchema above even for null values.  If we didn't   * make that call, we would fail to recognize fields in a positional set if any   * preceding fields in that set were blank.  For example:   *   *    name (first, middle, last): [William] [  ] [Clinton]    *   * With that said, at least we can skip the call to ResolveStateSchema in this   * case.  That call could be very time consuming because it involves looking   * looking backwards through all preceding text (possibly all the way to the   * beginning of the document) just to determine the state.  That is the purpose   * of the skipStateChecking argument.   */  if (!skipStateChecking && !schema.IsEmpty() && schema.First() == '$') {    wallet_ResolveStateSchema(elementNode, schema);   }  lastSchema.Assign(schema);  return;}