public static string MakeMainTable(Formato[] list)
        {
            String ret;
            ret = "<table border=1>\n";
            ret += "<tr>\n";
            ret += "<td>Nombre</td>";
            ret += "<td>Web</td>\n";
            ret += "<td>Une</td>\n";
            ret += "<td>Corta</td>\n</tr>\n";
            foreach (Formato f in list){

                ret += "<tr>\n";
                ret += "<td>" + MakeInternalRef (f.Name) + "</td>\n";
                ret += "<td>" + ((f.Web == "") ? "&nbsp;" : MakeWebRef (f.Web)) + "</td>\n";
                ret += "<td>" + ((f.SupportsJoin=="") ? "&nbsp;" : f.SupportsJoin) + "</td>\n";
                ret += "<td>" + ((f.SupportsSplit=="") ? "&nbsp;" : f.SupportsSplit) + "</td>\n";
                ret += "</tr>\n";
            }
            ret += "</table>\n";
            return ret;
        }
        public static void MakeIndexPage(Formato[] list, string template, string destDir)
        {
            string table = MakeMainTable (list);
            string plantilla = Fichero.CargarTexto (template);
            string indice = GenerarIndice (list);

            Console.WriteLine ("index");
            string salida = plantilla.Replace ("#TITLE#", "Dalle - Formatos");
            salida = salida.Replace ("#CONTENT#", table);
            salida = salida.Replace ("#MENU#", indice);

            Fichero.GuardarTexto (destDir + Path.DirectorySeparatorChar +"index.html", salida);
        }
        // Parámetros: <xml con formatos> <plantilla del indice> <plantilla de los formatos>  <directorio de destino>
        public static void Main(string [] args)
        {
            string input = args[0];
            string template_index = args[1];
            string template = args[2];
            string destDir = args[3];
            XmlDocument document = new XmlDocument();
            document.Load (input);
            nsmgr = new XmlNamespaceManager (document.NameTable);
            nsmgr.AddNamespace ("t", "http://dalle.sourceforge.net/formats.xsd");
            XmlNodeList formatos = document.SelectNodes ("/t:formats/t:format", nsmgr);

            Formato[] list = new Formato [formatos.Count];
            int count = 0;
            foreach (XmlNode node in formatos){
                list[count++] = new Formato(node);
            }

            Array.Sort (list, Formato.Comparer);
            MakeIndexPage (list, template_index, destDir);
            MakeAllPages (list, template, destDir);
        }
        public static void MakeAllPages(Formato[] list, string template, string destDir)
        {
            string plantilla = Fichero.CargarTexto (template);
            string indice = GenerarIndice(list);

            for (int i=0; i < list.Length; i++){
                Formato f = list[i];
                Console.WriteLine (f.Name);

                string salida = plantilla.Replace ("#TITLE#", "Dalle - " + f.Name);
                salida = salida.Replace ("#CONTENT#", f.Contenido);
                salida = salida.Replace ("#MENU#", indice);

                if (i > 0){
                    salida = salida.Replace (
                        "#PREVIOUS#",
                        String.Format (
                            "<a href=\"{0}.html\">Anterior ({0})</a>",
                            list[i-1].Name
                        )
                    );
                }
                else{
                    salida = salida.Replace ("#PREVIOUS#", "&nbsp;");
                }
                if ( i < (list.Length -1)){
                    salida = salida.Replace (
                        "#NEXT#",
                        String.Format (
                            "<a href=\"{0}.html\">Siguiente ({0})</a>",
                            list[i+1].Name
                        )
                    );
                }
                else{
                    salida = salida.Replace ("#NEXT#", "&nbsp;");
                }
                Fichero.GuardarTexto (destDir + "/" +f.Name + ".html", salida);
            }
        }
 public static string GenerarIndice(Formato[] list)
 {
     String ret = "<table>\n";
     foreach (Formato f in list){
         ret += "<tr><td>" + MakeInternalRef (f.Name) + "</td></tr>\n";
     }
     ret += "</table>\n";
     return ret;
 }