/* * IntDate.java * * Created on 16 septembre 2001, 02:40 */package be.fractals.soccer.servlet;import java.util.Date;import java.util.Calendar;import java.io.*;import org.w3c.dom.*;import com.sun.xml.tree.*;/** * * @author  aurelien * @version  */public class TableFormatter {    static int nColumns;    static NodeList nl;    /** Creates new IntDate */        public TableFormatter ( int n, NodeList l )    {        nColumns = n;        nl = l;    }        public TableFormatter ( int n ) {        nColumns = n;    }        public static String getTable () {        return getTable ( nl );    }        public static String getTable ( org.w3c.dom.NodeList nodelist ) {        nColumns = 3;        XmlDocument xml = new XmlDocument ();        Node root = xml.createElement("TABLE");        xml.appendChild(root);                Element currentRow = xml.createElement ( "TR" );        NodeList children = nodelist.item (0).getChildNodes ();        for ( int i=0; i<children.getLength (); i++ ) {            if ( ((i+1) % nColumns) == 1 ) {                currentRow = xml.createElement ( "TR" );                root.appendChild ( currentRow );            }            Element column = xml.createElement ( "TD" );            currentRow.appendChild ( column );            column.appendChild ( children.item ( i ) );        }        ByteArrayOutputStream baos = new ByteArrayOutputStream ();        try {            xml.write ( baos );        } catch ( Exception e ) {            return e.getMessage ();        }        return baos.toString ();    }        public void setNumberOfColumns ( int n )     {        nColumns = n;    }        }