public static boolean isTopLevelElement(XmlTag tag) {
    XmlTag p = tag;
    // not really necessary, XSLT doesn't allow literal result elements on top level anyway
    while ((p = p.getParentTag()) != null) {
      if (isXsltTag(p)) {
        return isXsltRootTag(p);
      }
    }
    return false;
  }
public static boolean isTopLevelElement(XmlTag tag)