List of usage examples for org.jdom2.output XMLOutputter XMLOutputter
public XMLOutputter()
XMLOutputter
with a default Format and XMLOutputProcessor . From source file:facturacion.utils.Util.java
public static org.w3c.dom.Document firmarComprobante(String proveedor, Document doc, InputStream token, String clave, String data) { org.w3c.dom.Document fileFirmado = null; File fileF = null;/*from w ww . ja v a 2s . co m*/ File aa = null; try { // validar que el token es null ante de firmarlo XAdESBESSignature firmar = new XAdESBESSignature((new DOMOutputter()).output(doc)); //XAdESBESSignature firmar = new XAdESBESSignature(); fileFirmado = firmar.execute(token, clave); //fileFirmado = firmar.execute(); //token.setFile(FtpServer.getTokenInputStream3(token.getFila_ruta())); //this.fileFirmado = firmar.execute(token.documentToInputStream(), token.getClave()); //this.fileFirmado = firmar.execute(); //creo el archivo firmado DOMBuilder builder = new DOMBuilder(); Document jdom = builder.build(fileFirmado); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); fileF = File.createTempFile("fileFirmado", ".xml"); //aa = new File("C:\\tributasoft\\prueba\\filePruebaFirmado"+data+".xml"); //FileWriter a = new FileWriter("C:\\tributasoft\\prueba\\filePruebaFirmado"+data+".xml"); //FileWriter a = new FileWriter(fileF); //FileWriter aaa = new FileWriter(aa); //xmlOutput.output(jdom, a); //xmlOutput.output(jdom, aaa); //aaa.close(); //a.close(); //this.clave_acceso = this.factura.getClaveAcceso(); System.out.println("----> firmar factura +++ 16"); } catch (JDOMException e) { // TODO Auto-generated catch block //System.out.println("----> firmar factura +++ 1"); e.printStackTrace(); //return ErrorSri.TOKEN; } catch (NullPointerException e) { // TODO Auto-generated catch block //System.out.println("----> firmar factura +++ 2"); e.printStackTrace(); //return ErrorSri.TOKEN; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return fileFirmado; //return ErrorSri.FIRMADO; }
From source file:geosolutions.zoom.system.XMLConfiguration.java
public boolean saveXmlParametrosSystem() { Cripto cripto = new Cripto(); Element root = new Element("cronos"); root.setAttribute("sistema", "Sistema Cronos"); //nodos hijos mayores Element servidor = new Element("servidor"); Element cliente = new Element("cliente"); Element otroServidor = new Element("otro_servidor"); Element otros = new Element("otros"); Element path = new Element("path"); //servidor//from ww w . j a v a 2s . c o m Element itemDriver = new Element("driver"); itemDriver.setText(ParametrosSystem.getDriverPostgres()); servidor.addContent(itemDriver); Element itemUrl = new Element("url"); itemUrl.setText(ParametrosSystem.getUrlPostgres()); servidor.addContent(itemUrl); Element itemIpServidor = new Element("ip_servidor"); itemIpServidor.setText(ParametrosSystem.getIpServidor()); servidor.addContent(itemIpServidor); Element itemNombreDB = new Element("db"); itemNombreDB.setText(ParametrosSystem.getBaseDatos()); servidor.addContent(itemNombreDB); Element itemNombrePcServidor = new Element("nombre_servidor"); itemNombrePcServidor.setText(ParametrosSystem.getNombrePcServidor()); servidor.addContent(itemNombrePcServidor); Element itemPuerto = new Element("puerto"); itemPuerto.setText(ParametrosSystem.getPuertoPostgres()); servidor.addContent(itemPuerto); Element itemUsuario = new Element("usuario"); itemUsuario.setText(ParametrosSystem.getUsuarioPostgres()); servidor.addContent(itemUsuario); Element itemPassword = new Element("password"); itemPassword.setText(cripto.Encriptar(ParametrosSystem.getPasswordPostgres(), 27)); servidor.addContent(itemPassword); Element itemNickCronos = new Element("nick"); itemNickCronos.setText(ParametrosSystem.getNickSistema()); servidor.addContent(itemNickCronos); //cliente Element itemIpCliente = new Element("ip_cliente"); itemIpCliente.setText(ParametrosSystem.getNombrePcCliente()); cliente.addContent(itemIpCliente); Element itemNombrePcCliente = new Element("nombre_cliente"); itemNombrePcCliente.setText(ParametrosSystem.getNombrePcCliente()); cliente.addContent(itemNombrePcCliente); //otro servidor Element itemIpOtroServidor = new Element("otro_ip_servidor"); itemIpOtroServidor.setText(ParametrosSystem.getOtroIpServidor()); otroServidor.addContent(itemIpOtroServidor); Element itemOtroPuerto = new Element("otro_puerto"); itemOtroPuerto.setText(ParametrosSystem.getOtroPuertoPostgres()); otroServidor.addContent(itemOtroPuerto); Element itemOtroDB = new Element("otro_db"); itemOtroDB.setText(ParametrosSystem.getOtroDB()); otroServidor.addContent(itemOtroDB); //otros Element itemEsServidor = new Element("es_servidor"); itemEsServidor.setText(ParametrosSystem.getEsServidor()); otros.addContent(itemEsServidor); Element itemOcurrioInterrupcion = new Element("interrupcion"); itemOcurrioInterrupcion.setText(ParametrosSystem.getInterrupcion()); otros.addContent(itemOcurrioInterrupcion); Element itemHoraCierrePlanilla = new Element("hora_cierre_planilla"); itemHoraCierrePlanilla.setText(ParametrosSystem.getHoraCierrePlanilla()); otros.addContent(itemHoraCierrePlanilla); Element itemEsAuotorizadoCopia = new Element("es_autorizado_backup"); itemEsAuotorizadoCopia.setText(ParametrosSystem.getEsAutorizado()); otros.addContent(itemEsAuotorizadoCopia); //path Element itemPathReporte = new Element("path_reporte"); itemPathReporte.setText(ParametrosSystem.getPathReport()); path.addContent(itemPathReporte); Element itemPathPgDump = new Element("path_pg_dump"); itemPathPgDump.setText(ParametrosSystem.getPathPgDumpPostgres()); path.addContent(itemPathPgDump); Element itemPathBackup = new Element("path_backup"); itemPathBackup.setText(ParametrosSystem.getPathBackup()); path.addContent(itemPathBackup); //agregamos al root root.addContent(servidor); root.addContent(cliente); root.addContent(otroServidor); root.addContent(otros); root.addContent(path); // Realizamos lo mismo con los elementos restantes XMLOutputter outputter = new XMLOutputter(); try { outputter.output(new Document(root), new FileOutputStream("cronos.xml")); return true; } catch (Exception e) { e.getMessage(); return false; } }
From source file:gestores.IODocumentos.java
public static boolean exportarDocumento(Documento documento, String URL) { try {/*from w w w . ja v a 2 s. com*/ Element documentoXML = new Element("documento"); documentoXML.addContent(new Element("URL").setText(documento.getURL())); documentoXML.addContent(new Element("nombre").setText(documento.getNombreDocumento())); documentoXML.addContent(new Element("carpeta").setText(documento.getURLDirectorioPadre())); for (Palabra palabra : documento.getVocabularioArrayList()) { Element xmlPalabra = new Element("palabra"); xmlPalabra.addContent(new Element("nombre").setText(palabra.getPalabra())); xmlPalabra.addContent(new Element("frecuencia").setText(Integer.toString(palabra.getFrecuencia()))); documentoXML.addContent(xmlPalabra); } URL += "\\" + documento.getNombreDocumento() + ".xml"; Document archivoDeSalida = new Document(documentoXML); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(archivoDeSalida, new FileWriter(URL)); return true; } catch (IOException e) { return false; } }
From source file:gestores.IOMapeadorURLs.java
public static void exportarMapeadorSAX(MapeadorDeURLs mapeador, String URL) throws IOException { ArrayList<Mapeo> mapeos = mapeador.getMapeosOrdenadosPorCodigoMapping(); Element documentoXML = new Element(Configuracion.marcaElementoRootMapeador); for (Mapeo elemento : mapeos) { Element mapeo = new Element(Configuracion.marcaMapeoMapeador); mapeo.addContent(new Element(Configuracion.marcaURLMapeador).setText(elemento.getURL())); mapeo.addContent(// ww w .ja va 2s . c o m new Element(Configuracion.marcaMappingMapeador).setText(Integer.toString(elemento.getMap()))); documentoXML.addContent(mapeo); } Document archivoDeSalida = new Document(documentoXML); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(archivoDeSalida, new FileWriter(URL)); }
From source file:gestores.IOPosteo.java
private static void exportarSAX(Posteo posteo, String URL) throws IOException { Element elementoRaiz = obtenerEstructuraDeExportacionDeListas(posteo); Document archivoDeSalida = new Document(elementoRaiz); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(archivoDeSalida, new FileWriter(URL)); }
From source file:gestores.IOVocabularioGeneral.java
private static void exportarVocabularioSAX(VocabularioGeneral vocabulario, String URL) throws IOException { Element documentoXML = new Element(Configuracion.marcaElementoRootVocabulario); ArrayList<EntradaVocabularioGeneral> entradas = vocabulario.getEntradasDelVocabulario(); Collections.sort(entradas);/*from w w w . java 2 s .c o m*/ for (EntradaVocabularioGeneral entrada : entradas) { Element entradaXML = new Element(Configuracion.marcaEntradaVocabulario); entradaXML.addContent(new Element(Configuracion.marcaPalabraVocabulario).setText(entrada.getPalabra())); entradaXML.addContent(new Element(Configuracion.marcaFrecuenciaVocabulario) .setText(Integer.toString(entrada.getFrecuencia()))); entradaXML.addContent(new Element(Configuracion.marcaFrecuenciaMaximaVocabulario) .setText(Integer.toString(entrada.getFrecuenciaMaxima()))); entradaXML.addContent(new Element(Configuracion.marcaCantidadDocumentosVocabulario) .setText(Integer.toString(entrada.getDocumentosEnQueAparece()))); documentoXML.addContent(entradaXML); } /*if(nombreDelArchivo == null || nombreDelArchivo.equals("")){ nombreDelArchivo = "vocabularioGeneral.xml"; }*/ Document archivoDeSalida = new Document(documentoXML); XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(archivoDeSalida, new FileWriter(URL)); }
From source file:ilarkesto.integration.jdom.JDom.java
License:Open Source License
public static void save(Document doc, File file, String encoding) { IO.createDirectory(file.getParentFile()); Writer out;/*from www. j a va 2 s. c om*/ try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding)); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } catch (FileNotFoundException ex) { throw new RuntimeException(ex); } XMLOutputter outputter = new XMLOutputter(); outputter.getFormat().setEncoding(encoding); try { outputter.output(doc, out); } catch (IOException ex) { throw new RuntimeException(ex); } IO.close(out); }
From source file:ilarkesto.integration.jdom.JDom.java
License:Open Source License
public static void write(Document doc, OutputStream out, String encoding) { XMLOutputter outputter = new XMLOutputter(); outputter.getFormat().setEncoding(encoding); try {/*from w w w . ja v a 2 s. c o m*/ outputter.output(doc, out); } catch (IOException ex) { throw new RuntimeException(ex); } IO.close(out); }
From source file:info.okoshi.trifulx.Xml.java
License:Open Source License
/** * Write XML to output stream.<br> * Output stream will be closed on finally.<br> * * @param out/* ww w .j a va2 s . co m*/ * Output stream * @param charset * Character set * @throws IOException * I/O exception */ public void save(OutputStream out, Charset charset) throws IOException { try { Format jdomFormat = Format.getPrettyFormat(); jdomFormat.setEncoding(charset.name()); XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(jdomFormat); outputter.output(document, out); } finally { out.close(); } }
From source file:info.okoshi.trifulx.Xml.java
License:Open Source License
/** * XML to text.<br>/* w w w . jav a 2 s .co m*/ * * @param types * Type of formatting * @param charset * Character set * @return XML text */ public String text(FormatTypes types, Charset charset) { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(types.jdomFormat(charset)); return outputter.outputString(document); }