public static Cons expandXmlTagCase(Symbol item, Cons clauses) {
    { Cons outputClauses = Stella.NIL;
      Stella_Object key = null;

      { Cons clause = null;
        Cons iter000 = clauses;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          clause = ((Cons)(iter000.value));
          key = clause.value;
          { Surrogate testValue000 = Stella_Object.safePrimaryType(key);

            if (testValue000 == Stella.SGT_STELLA_CONS) {
              { Cons key000 = ((Cons)(key));

                if (key000.rest == Stella.NIL) {
                  outputClauses = Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_XML_ELEMENT_MATCHp, Cons.cons(item, Cons.cons(Cons.cons(key000.value, Cons.cons(Stella.SYM_STELLA_NULL, Stella.NIL)), Stella.NIL)))), clause.rest.concatenate(Stella.NIL, Stella.NIL)), outputClauses);
                }
                else if (key000.rest.value == Stella.KWD_ANY) {
                  outputClauses = Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_STRING_EQLp, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_NAME, Cons.cons(item, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(key000.value, Cons.cons(Stella.NIL, Stella.NIL))))), clause.rest.concatenate(Stella.NIL, Stella.NIL)), outputClauses);
                }
                else {
                  outputClauses = Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_XML_ELEMENT_MATCHp, Cons.cons(item, Cons.cons(Cons.cons(key000.value, Cons.cons(key000.rest.value, Stella.NIL)), Stella.NIL)))), clause.rest.concatenate(Stella.NIL, Stella.NIL)), outputClauses);
                }
              }
            }
            else if (Surrogate.subtypeOfSymbolP(testValue000)) {
              { Symbol key000 = ((Symbol)(key));

                if (key000 == Stella.SYM_STELLA_OTHERWISE) {
                  outputClauses = Cons.cons(clause, outputClauses);
                }
                else {
                  outputClauses = Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_XML_ELEMENT_MATCHp, Cons.cons(item, Cons.cons(Cons.cons(StringWrapper.wrapString(key000.symbolName), Cons.cons(Stella.SYM_STELLA_NULL, Stella.NIL)), Stella.NIL)))), clause.rest.concatenate(Stella.NIL, Stella.NIL)), outputClauses);
                }
              }
            }
            else if (Surrogate.subtypeOfStringP(testValue000)) {
              { StringWrapper key000 = ((StringWrapper)(key));

                outputClauses = Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_XML_ELEMENT_MATCHp, Cons.cons(item, Cons.cons(Cons.cons(key000, Cons.cons(Stella.SYM_STELLA_NULL, Stella.NIL)), Stella.NIL)))), clause.rest.concatenate(Stella.NIL, Stella.NIL)), outputClauses);
              }
            }
            else {
              { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
                throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
              }
            }
          }
        }
      }
      return (Cons.cons(Stella.SYM_STELLA_COND, outputClauses.reverse().concatenate(Stella.NIL, Stella.NIL)));
    }
  }