Example usage for org.jdom2.output Format getPrettyFormat

List of usage examples for org.jdom2.output Format getPrettyFormat

Introduction

In this page you can find the example usage for org.jdom2.output Format getPrettyFormat.

Prototype

public static Format getPrettyFormat() 

Source Link

Document

Returns a new Format object that performs whitespace beautification with 2-space indents, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy.

Usage

From source file:lu.list.itis.dkd.aig.util.DocumentConverter.java

License:Apache License

/**
 * Method for converting a {@link Document} instance into its XML
 * {@link String} representation.//from   www .j  av a2s  .  c om
 *
 * @param document
 *            The {@link Document} instance to convert.
 * @return The {@link String} representation of the document using an
 *         {@link XMLOutputter} and setting {@link Format} to pretty print.
 */
@SuppressWarnings("null")
public static String convertDocumentToString(final Document document) {

    final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    return outputter.outputString(document);
}

From source file:lu.list.itis.dkd.assess.cloze.template.Template.java

License:Apache License

public void save(String path, String name) {
    Document doc = new Document();
    Element template = new Element("template");
    template.addContent(metaData());/*from   w  ww .  j av a  2  s.  com*/
    template.addContent(layer());
    doc.addContent(template);

    XMLOutputter xmlOutput = new XMLOutputter();
    xmlOutput.setFormat(Format.getPrettyFormat());
    try {
        xmlOutput.output(doc, new FileWriter(path + name + ".xml"));
    } catch (IOException e) {
        logger.log(Level.SEVERE, "Problem saving template", e);
        e.printStackTrace();
    }

    logger.log(Level.INFO, "File saved to " + path + name + ".xml.");
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * //  ww w. j a v  a2 s . c o m
 * @param inName
 * @throws IOException
 */
static void printHTMLFrame(String inName) throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = addHeader("Sources")
            .addContent(new Element("frameset").setAttribute("id", "mainframe").setAttribute("cols", "20%, 80%")
                    .addContent(new Element("frameset").setAttribute("id", "mainframe")
                            .setAttribute("rows", "20%, 50%, 30%")
                            .addContent(new Element("frame").setAttribute("name", "tags").setAttribute("src",
                                    FileUtils.getRelTagListeName()))
                            .addContent(new Element("frame").setAttribute("name", "source").setAttribute("src",
                                    FileUtils.getRelNilName()))
                            .addContent(new Element("frame").setAttribute("name", "target").setAttribute("src",
                                    FileUtils.getRelNilName())))
                    .addContent(new Element("frameset").setAttribute("id", "mainframe")
                            .setAttribute("rows", "50%, 50%")
                            .addContent(new Element("frame").setAttribute("name", "doku").setAttribute("src",
                                    FileUtils.getRelDxygeDokuName()))
                            .addContent(new Element("frame").setAttribute("name", "details").setAttribute("src",
                                    FileUtils.getRelNilName()))));

    outFile(inName, out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * /*from w  w w  . j av a  2 s.co  m*/
 * 
 * @throws IOException
 */
static void printHTMLNil() throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = new Element("html").addContent(new Element("head"))
            .addContent(new Element("body").addContent(new Element("p").setText("Leer")));

    outFile(FileUtils.getNilName(), out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * /*w  w w.  j av a2  s  . c  om*/
 * @param listeSource
 * @param listeTyp
 * @param nodeLinkListe
 * @param inNodeTag
 * @throws IOException
 */
static void printHTMLSource(List<NodeSource> listeSource, List<NodeTyp> listeTyp,
        List<NodeTarget> nodeLinkListe, NodeTag inNodeTag) throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = new Element("html").addContent(new Element("title").setText("Sources"));
    Element body = new Element("body");
    element.addContent(body);

    int count = 0;
    for (NodeSource node : listeSource) {
        if (node.getName().equals(inNodeTag.getName())) {
            count++;
        }
    }
    if (count == 0) {
        body.addContent(new Element("p").setText(String.format("No reference for: %s", inNodeTag.getName())));
    } else {
        for (NodeSource node : listeSource) {
            if (node.getName().equals(inNodeTag.getName())) {
                body.addContent(new Element("p").addContent(new Element("a")
                        .setText(String.format("%s %s", node.getName(), node.getNummer()))
                        .setAttribute("href", FileUtils.getRelLinkName(node)).setAttribute("target", "target")
                        .setAttribute("title", "Beschreibung der Klasse").setAttribute("onclick",
                                String.format("top.doku.location='%s'; return true;", node.getFileName()))));

                GenerateHTML.printHTMLLink(node, listeTyp, nodeLinkListe);
            }
        }
    }

    outFile(FileUtils.getSourceName(inNodeTag), out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * // w  ww. j  av a  2 s.c om
 * @param liste
 * @param listeSource
 * @param listeTyp
 * @param listeLink
 * @throws IOException
 */
static void printHTMLTags(List<NodeTag> liste, List<NodeSource> listeSource, List<NodeTyp> listeTyp,
        List<NodeTarget> listeLink) throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = addHeader("Sources");
    Element body = new Element("body");
    element.addContent(body);

    for (NodeTag nodeTag : liste) {
        Element link = new Element("p").setText(String.format("%s", nodeTag.getName()));
        body.addContent(link);

        link.addContent(new Element("a").setText(nodeTag.getName())
                .setAttribute("href", FileUtils.getRelSourceName(nodeTag)).setAttribute("target", "source"));

        GenerateHTML.printHTMLSource(listeSource, listeTyp, listeLink, nodeTag);
    }

    outFile(FileUtils.getTagListeName(), out.outputString(element));
}

From source file:main.GenerateHTML.java

License:Open Source License

/**
 * /* w ww .j a v a  2s . co m*/
 * @param nodeQuelle
 * @param listeTyp
 * @param nodeLinkList
 * @throws IOException
 */
static void printHTMLLink(NodeSource nodeQuelle, List<NodeTyp> listeTyp, List<NodeTarget> nodeLinkList)
        throws IOException {
    Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true);
    XMLOutputter out = new XMLOutputter(expanded);

    Element element = addHeader("Sources");
    Element body = new Element("body").addContent(new Element("h3")
            .setText(String.format("Links: %s %s", nodeQuelle.getName(), nodeQuelle.getNummer())));
    element.addContent(body);

    // Count number of referencwes
    int count = 0;
    for (NodeTyp node : listeTyp) {
        for (NodeTarget nodeLink : nodeLinkList) {
            if (nodeLink.getTyp().equals(node.getName())) {
                if (nodeQuelle.getName().equals(nodeLink.getName())
                        & nodeQuelle.getNummer().equals(nodeLink.getNummer())) {
                    count++;
                }
            }
        }
    }
    if (count == 0) {
        body.addContent(new Element("p").setText("No Links"));
    } else {
        for (NodeTyp node : listeTyp) {
            int countLink = 0;
            for (NodeTarget nodeLink : nodeLinkList) {
                if (nodeLink.getTyp().equals(node.getName())) {
                    if (nodeQuelle.getName().equals(nodeLink.getName())
                            & nodeQuelle.getNummer().equals(nodeLink.getNummer())) {
                        countLink++;
                    }
                }
            }
            if (countLink == 0) {
                body.addContent(new Element("p").setText(String.format("%s: no Element", node.getName())));
            } else {
                for (NodeTarget nodeLink : nodeLinkList) {
                    if (nodeLink.getTyp().equals(node.getName())) {
                        if (nodeQuelle.getName().equals(nodeLink.getName())
                                & nodeQuelle.getNummer().equals(nodeLink.getNummer())) {
                            body.addContent(new Element("p").setText(node.getName())
                                    .addContent(new Element("a").setText(nodeLink.getName())
                                            .setAttribute("href", nodeLink.getFileName())
                                            .setAttribute("title", "Beschreibung der Klasse")
                                            .setAttribute("target", "details")));

                        }
                    }
                }
            }
        }
    }

    outFile(FileUtils.getLinkName(nodeQuelle), out.outputString(element));
}

From source file:main.Var.java

License:Open Source License

private static void XMLSave(String ruta) {
    try {//from  www  . j av  a  2  s. co m
        Element ele;
        SAXBuilder builder = new SAXBuilder();
        File xmlFile = new File(ruta);

        Document document = (Document) builder.build(xmlFile);
        Element config = document.getRootElement();

        Element conexion = config.getChild("conexion");
        ele = conexion.getChild("db-host");
        ele.setText(con.getDireccion());
        ele = conexion.getChild("db-port");
        ele.setText(con.getPuerto());
        ele = conexion.getChild("db-username");
        ele.setText(con.getUsuario());
        ele = conexion.getChild("db-password");
        ele.setText(con.getPass());

        Element ftp = config.getChild("ftp");
        ele = ftp.getChild("ftp-host");
        ele.setText(conFtp.getHost());
        ele = ftp.getChild("ftp-port");
        ele.setText(Integer.toString(conFtp.getPort()));
        ele = ftp.getChild("ftp-user");
        ele.setText(conFtp.getUser());
        ele = ftp.getChild("ftp-pass");
        ele.setText(conFtp.getPass());

        Element admin = config.getChild("modoAdmin");
        ele = admin.getChild("activo");
        if (modoAdmin) {
            ele.setText("true");
        } else {
            ele.setText("false");
        }
        ele = admin.getChild("password");
        ele.setText(passwordAdmin);
        ele = admin.getChild("query-limit");
        ele.setText(queryLimit);

        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
        try {
            outputter.output(document, new FileOutputStream(configFile));
        } catch (Exception e) {
            e.getMessage();
        }

    } catch (JDOMException | IOException ex) {
        Logger.getLogger(Var.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:metodos.MetodosAjedrez.java

License:Open Source License

/**
 * Mtodo que guarda los datos en un archivo XML
 * @param ruta/*from  w  w w .  ja v  a  2  s . c o  m*/
 * @param nombreArchivo
 */
@Override
public void guardarXML(String ruta, String nombreArchivo) {

    //Variables auxiliaes
    int num_partidos;
    int num_equipos;

    try {

        Document doc = new Document();
        Element xml_torneo = new Element("torneo");
        doc.setRootElement(xml_torneo);

        //Elementos principales del torneo
        Element xml_nombreTorneo = new Element("nombreTorneo");
        xml_nombreTorneo.setText(nombreTorneo);
        doc.getRootElement().addContent(xml_nombreTorneo);

        Element xml_tipoTorneo = new Element("tipoTorneo");
        xml_tipoTorneo.setText(Integer.toString(tipoTorneo));
        doc.getRootElement().addContent(xml_tipoTorneo);

        Element xml_deporte = new Element("deporte");
        xml_deporte.setText(Integer.toString(deporte));
        doc.getRootElement().addContent(xml_deporte);

        Element xml_num_jornadas = new Element("jornadas");
        xml_num_jornadas.setText(Integer.toString(num_jornadas));
        doc.getRootElement().addContent(xml_num_jornadas);

        Element xml_idaVuelta = new Element("idaVuelta");
        xml_idaVuelta.setText(Boolean.toString(idaVuelta));
        doc.getRootElement().addContent(xml_idaVuelta);

        Element xml_sets = new Element("sets");
        xml_sets.setText(Integer.toString(sets));
        doc.getRootElement().addContent(xml_sets);

        Element xml_sorteo = new Element("sorteo");
        xml_sorteo.setText(Boolean.toString(sorteo));
        doc.getRootElement().addContent(xml_sorteo);

        Element xml_tercerCuartoPuesto = new Element("tercerCuartoPuesto");
        xml_tercerCuartoPuesto.setText(Boolean.toString(tercerCuartoPuesto));
        doc.getRootElement().addContent(xml_tercerCuartoPuesto);

        Element xml_sanciones = new Element("sanciones");
        if (sancionados.size() > 0) {//Si hay sancionados procedemos a guardarlos            
            for (Map.Entry<String, Integer> entry : getSancionados().entrySet()) {
                Element xml_sancionado = new Element("sancionado");
                //Aadimos el nombre del sancionado
                Element xml_nombreSancionado = new Element("nombreSancionado");
                xml_nombreSancionado.setText(entry.getKey());
                xml_sancionado.addContent(xml_nombreSancionado);
                //Aadimos los puntos de sancin
                Element xml_sancion = new Element("sancion");
                xml_sancion.setText(Integer.toString(entry.getValue()));
                xml_sancionado.addContent(xml_sancion);
                //Aadimos el sancionado a la lista de sanciones
                xml_sanciones.addContent(xml_sancionado);
            } //end for HashMap
        } //end if
        doc.getRootElement().addContent(xml_sanciones);

        //Calendario y jornadas con sus partidos
        Element xml_calendario = new Element("calendario");
        for (int i = 0; i < num_jornadas; i++) {
            //Recorremos todos los partidos del objeto jornada (nmero i) para obtener los datos de cada partido y asginarlos a los elementos
            Jornada J = getCalendario().jornadas.get(i);//i porque es un ndice

            Element xml_jornada = new Element("jornada");
            //Aadimos como atributo el nmero de jornada                
            xml_jornada.setAttribute(new Attribute("numero", Integer.toString(i + 1)));

            //Ahora usamos el for-each y obtenemos la lista de partidos de este objeto Jornada
            for (PartidoAjedrez partido : (ArrayList<PartidoAjedrez>) J.getListaPartidos()) {

                //Creamos un elemento partido por cada partido en la lista
                Element xml_partido = new Element("partido");

                xml_partido.addContent(new Element("fecha").setText(partido.getFecha()));
                xml_partido.addContent(new Element("hora").setText(partido.getHora()));
                xml_partido.addContent(new Element("local").setText(partido.getLocal()));
                xml_partido.addContent(new Element("blancas").setText((Double.toString(partido.getBlancas()))));//Convertimos los valores enteros a String
                xml_partido.addContent(new Element("negras").setText((Double.toString(partido.getNegras()))));
                xml_partido.addContent(new Element("visitante").setText(partido.getVisitante()));
                xml_partido.addContent(new Element("pista").setText(partido.getPista()));

                xml_jornada.addContent(xml_partido);
            }
            //Aadimos la jornada al documento XML
            xml_calendario.addContent(xml_jornada);

        }
        doc.getRootElement().addContent(xml_calendario);

        //Aadimos ahora los datos de la clasificacin
        num_equipos = castEquipoLista.getEquipos().size();

        Element xml_clasificacion = new Element("clasificacion");

        for (EquipoAjedrez equipo : (ArrayList<EquipoAjedrez>) getCastEquipoLista().getEquipos())
            //Si el local o el visitante descansan ignoramos la accin
            if (equipo.getNombre().equalsIgnoreCase("EquipoFantasma")) {
                //No hagas nada pues no este equipo es el comodn para los torneos impares
            } else {
                Element xml_equipo = new Element("equipo");

                xml_equipo.addContent(new Element("numero").setText(Integer.toString(equipo.getNumero())));
                xml_equipo.addContent(new Element("team").setText(equipo.getNombre()));
                xml_equipo.addContent(
                        new Element("posicion").setText(Integer.toString(equipo.getPosicion() + 1)));
                xml_equipo.addContent(new Element("pj").setText(Integer.toString(equipo.getPj())));
                xml_equipo.addContent(new Element("pg").setText(Integer.toString(equipo.getPg())));
                xml_equipo.addContent(new Element("pe").setText(Integer.toString(equipo.getPe())));
                xml_equipo.addContent(new Element("pp").setText(Integer.toString(equipo.getPp())));
                xml_equipo.addContent(new Element("ptosAj").setText(Double.toString(equipo.getPtos())));
                xml_equipo.addContent(new Element("sb").setText(Double.toString(equipo.getSb())));

                xml_clasificacion.addContent(xml_equipo);
            }

        doc.getRootElement().addContent(xml_clasificacion);

        // new XMLOutputter().output(doc, System.out);
        XMLOutputter xmlOutput = new XMLOutputter();

        // display nice nice
        xmlOutput.setFormat(Format.getPrettyFormat());
        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(ruta + "/" + nombreArchivo), "UTF8"));//Lo utiliamos para asignar utf-8 (as funciona)

        //Creamos el archivo xml con FileWriter(el formato se supone que ya viene dado)
        //xmlOutput.output(doc, new FileWriter(ruta+"/"+nombreArchivo)); //"competiciones/torneo.xml"
        xmlOutput.output(doc, out);//resuelve los problemas de encoding utf-8 que se daban fuera de Netbeans

        JOptionPane.showMessageDialog(null,
                "<html>Archivo <b>" + nombreArchivo + "</b> guardado con xito</html>", "Guardar Archivo",
                JOptionPane.INFORMATION_MESSAGE, null);
    } catch (IOException io) {
        System.out.println(io.getMessage());
    }

}

From source file:metodos.MetodosBadminton.java

License:Open Source License

/**
 * Mtodo que guarda los datos en un archivo XML
 * @param ruta//w w w  .j  a  v  a  2s . c om
 * @param nombreArchivo
 */
@Override
public void guardarXML(String ruta, String nombreArchivo) {

    //Variables auxiliaes
    int num_partidos;
    int num_equipos;

    try {

        Document doc = new Document();
        Element xml_torneo = new Element("torneo");
        doc.setRootElement(xml_torneo);

        //Elementos principales del torneo
        Element xml_nombreTorneo = new Element("nombreTorneo");
        xml_nombreTorneo.setText(nombreTorneo);
        doc.getRootElement().addContent(xml_nombreTorneo);

        Element xml_tipoTorneo = new Element("tipoTorneo");
        xml_tipoTorneo.setText(Integer.toString(tipoTorneo));
        doc.getRootElement().addContent(xml_tipoTorneo);

        Element xml_deporte = new Element("deporte");
        xml_deporte.setText(Integer.toString(deporte));
        doc.getRootElement().addContent(xml_deporte);

        Element xml_num_jornadas = new Element("jornadas");
        xml_num_jornadas.setText(Integer.toString(num_jornadas));
        doc.getRootElement().addContent(xml_num_jornadas);

        Element xml_idaVuelta = new Element("idaVuelta");
        xml_idaVuelta.setText(Boolean.toString(idaVuelta));
        doc.getRootElement().addContent(xml_idaVuelta);

        Element xml_sets = new Element("sets");
        xml_sets.setText(Integer.toString(sets));
        doc.getRootElement().addContent(xml_sets);

        Element xml_sorteo = new Element("sorteo");
        xml_sorteo.setText(Boolean.toString(sorteo));
        doc.getRootElement().addContent(xml_sorteo);

        Element xml_tercerCuartoPuesto = new Element("tercerCuartoPuesto");
        xml_tercerCuartoPuesto.setText(Boolean.toString(tercerCuartoPuesto));
        doc.getRootElement().addContent(xml_tercerCuartoPuesto);

        Element xml_sanciones = new Element("sanciones");
        if (sancionados.size() > 0) {//Si hay sancionados procedemos a guardarlos            
            for (Map.Entry<String, Integer> entry : getSancionados().entrySet()) {
                Element xml_sancionado = new Element("sancionado");
                //Aadimos el nombre del sancionado
                Element xml_nombreSancionado = new Element("nombreSancionado");
                xml_nombreSancionado.setText(entry.getKey());
                xml_sancionado.addContent(xml_nombreSancionado);
                //Aadimos los puntos de sancin
                Element xml_sancion = new Element("sancion");
                xml_sancion.setText(Integer.toString(entry.getValue()));
                xml_sancionado.addContent(xml_sancion);
                //Aadimos el sancionado a la lista de sanciones
                xml_sanciones.addContent(xml_sancionado);
            } //end for HashMap
        } //end if
        doc.getRootElement().addContent(xml_sanciones);

        //Calendario y jornadas con sus partidos
        Element xml_calendario = new Element("calendario");
        for (int i = 0; i < num_jornadas; i++) {
            //Recorremos todos los partidos del objeto jornada (nmero i) para obtener los datos de cada partido y asginarlos a los elementos
            Jornada J = getCalendario().jornadas.get(i);//i porque es un ndice

            Element xml_jornada = new Element("jornada");
            //Aadimos como atributo el nmero de jornada                
            xml_jornada.setAttribute(new Attribute("numero", Integer.toString(i + 1)));

            //Ahora usamos el for-each y obtenemos la lista de partidos de este objeto Jornada
            for (PartidoTenis3Sets partido : (ArrayList<PartidoTenis3Sets>) J.getListaPartidos()) {

                //Creamos un elemento partido por cada partido en la lista
                Element xml_partido = new Element("partido");

                xml_partido.addContent(new Element("fecha").setText(partido.getFecha()));
                xml_partido.addContent(new Element("hora").setText(partido.getHora()));
                xml_partido.addContent(new Element("local").setText(partido.getLocal()));
                xml_partido.addContent(new Element("set1L").setText((Integer.toString(partido.getSet1L()))));//Convertimos los valores enteros a String
                xml_partido.addContent(new Element("set1V").setText((Integer.toString(partido.getSet1V()))));
                xml_partido.addContent(new Element("set2L").setText((Integer.toString(partido.getSet2L()))));
                xml_partido.addContent(new Element("set2V").setText((Integer.toString(partido.getSet2V()))));
                xml_partido.addContent(new Element("set3L").setText((Integer.toString(partido.getSet3L()))));
                xml_partido.addContent(new Element("set3V").setText((Integer.toString(partido.getSet3V()))));
                xml_partido.addContent(new Element("visitante").setText(partido.getVisitante()));
                xml_partido.addContent(new Element("pista").setText(partido.getPista()));

                xml_jornada.addContent(xml_partido);
            }
            //Aadimos la jornada al documento XML
            xml_calendario.addContent(xml_jornada);

        }
        doc.getRootElement().addContent(xml_calendario);

        //Aadimos ahora los datos de la clasificacin
        num_equipos = castEquipoLista.getEquipos().size();

        Element xml_clasificacion = new Element("clasificacion");

        for (EquipoTenis equipo : (ArrayList<EquipoTenis>) getCastEquipoLista().getEquipos())
            //Si el local o el visitante descansan ignoramos la accin
            if (equipo.getNombre().equalsIgnoreCase("EquipoFantasma")) {
                //No hagas nada pues no este equipo es el comodn para los torneos impares
            } else {
                Element xml_equipo = new Element("equipo");

                xml_equipo.addContent(new Element("numero").setText(Integer.toString(equipo.getNumero())));
                xml_equipo.addContent(new Element("team").setText(equipo.getNombre()));
                xml_equipo.addContent(
                        new Element("posicion").setText(Integer.toString(equipo.getPosicion() + 1)));
                xml_equipo.addContent(new Element("pj").setText(Integer.toString(equipo.getPj())));
                xml_equipo.addContent(new Element("pg").setText(Integer.toString(equipo.getPg())));
                xml_equipo.addContent(new Element("pp").setText(Integer.toString(equipo.getPp())));
                xml_equipo.addContent(new Element("sf").setText(Integer.toString(equipo.getSf())));
                xml_equipo.addContent(new Element("sc").setText(Integer.toString(equipo.getSc())));
                xml_equipo.addContent(new Element("jf").setText(Integer.toString(equipo.getJf())));
                xml_equipo.addContent(new Element("jc").setText(Integer.toString(equipo.getJc())));

                xml_clasificacion.addContent(xml_equipo);
            }

        doc.getRootElement().addContent(xml_clasificacion);

        // new XMLOutputter().output(doc, System.out);
        XMLOutputter xmlOutput = new XMLOutputter();

        // display nice nice
        xmlOutput.setFormat(Format.getPrettyFormat());
        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(ruta + "/" + nombreArchivo), "UTF8"));//Lo utiliamos para asignar utf-8 (as funciona)

        //Creamos el archivo xml con FileWriter(el formato se supone que ya viene dado)
        //xmlOutput.output(doc, new FileWriter(ruta+"/"+nombreArchivo)); //"competiciones/torneo.xml"
        xmlOutput.output(doc, out);//resuelve los problemas de encoding utf-8 que se daban fuera de Netbeans

        JOptionPane.showMessageDialog(null,
                "<html>Archivo <b>" + nombreArchivo + "</b> guardado con xito</html>", "Guardar Archivo",
                JOptionPane.INFORMATION_MESSAGE, null);
    } catch (IOException io) {
        System.out.println(io.getMessage());
    }

}