Esempio n. 1
0
 public static void dumpWiki(XmlTagHandler root, PrintStream out) {
   try {
     dumpNodeWiki(root, out, 1);
   } catch (XmlTagException exc) {
     out.println("Error traversing tags: " + exc.getMessage());
   }
 }
Esempio n. 2
0
  private static void dumpNodeWiki(XmlTagHandler tag, PrintStream out, int indent)
      throws XmlTagException {
    XmlTagInfo[] subTags = tag.getSubTags();

    if (indent == 1) {
      out.println(StringUtil.repeatChars('*', indent) + " Tag *<" + tag.getName() + ">*: ");
    }

    if (tag instanceof XmlAttrHandler) {
      XmlAttr[] attrs;

      attrs = ((XmlAttrHandler) tag).getAttributes();

      dumpAttrsWiki(attrs, "*REQUIRED*", XmlAttr.REQUIRED, out, indent + 1);
      dumpAttrsWiki(attrs, "*OPTIONAL*", XmlAttr.OPTIONAL, out, indent + 1);
    }

    subTags = tag.getSubTags();
    if (subTags.length != 0) {

      for (int i = 0; i < subTags.length; i++) {
        String name = subTags[i].getTag().getName();
        int type = subTags[i].getType();
        String desc = "";

        switch (type) {
          case XmlTagInfo.REQUIRED:
            desc = "REQUIRED";
            break;
          case XmlTagInfo.OPTIONAL:
            desc = "OPTIONAL";
            break;
          case XmlTagInfo.ONE_OR_MORE:
            desc = "REQUIRED at least ONCE";
            break;
          case XmlTagInfo.ZERO_OR_MORE:
            desc = "can be specified any # of times";
            break;
        }

        out.println(StringUtil.repeatChars('*', indent + 1) + " Sub Tag *<" + name + ">* " + desc);
        dumpNodeWiki(subTags[i].getTag(), out, indent + 1);
      }
    }
  }