Package org.jdom2.output

Examples of org.jdom2.output.DOMOutputter.output()


      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#x10000;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root att=\"&#xd800;&#xdc00; &#xd800;&#xdc00;\"/>" + format.getLineSeparator(), xml);
    }
View Full Code Here


      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#65536;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root att=\"&#xd800;&#xdc00; &#xd800;&#xdc00;\"/>" + format.getLineSeparator(), xml);
    }
View Full Code Here

      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root>&#xd800;&#xdc00;</root>" + format.getLineSeparator(), xml);
    }
View Full Code Here

      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("UTF-8");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      StringWriter baos = new StringWriter();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + format.getLineSeparator() +
                   "<root>\uD800\uDC00</root>" + format.getLineSeparator(), xml);
    }
View Full Code Here

      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      try {
        outputter.output(doc, xsw);
        fail("Illegal surrogate pair output should have thrown an exception");
      }
      catch (XMLStreamException e) {
        // do nothing
      } catch (Exception e) {
View Full Code Here

                FileOutputStream fileOutputStream = new FileOutputStream(file);
                Format format = Format.getPrettyFormat();
                format.setEncoding("utf-16");
                format.setTextMode(Format.TextMode.TRIM);
                XMLOutputter outputter = new XMLOutputter(format);
                outputter.output(new Document(root), fileOutputStream);
                fileOutputStream.close();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
View Full Code Here

  private void saveXML()
  {
     try
     {
        XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
        sortie.output(this.root, new FileOutputStream(SQCalculator.xmlPath));
     }
     catch (java.io.IOException e){}
  }
 
  public double[] getSQ()
View Full Code Here

  private void saveXML()
  {
     try
     {
        XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
        sortie.output(la.root, new FileOutputStream(Language.xmlPath));
     }
     catch (java.io.IOException e){}
  }
}
View Full Code Here

            }         
          }
          XMLOutputter xmlOutput = new XMLOutputter();
          //display nice
          xmlOutput.setFormat(Format.getPrettyFormat());
          xmlOutput.output(xml, new FileWriter(file));
          System.out.println("------------Correction finished for "+file.getName()+"-------------------------");
        }
        catch(JDOMException e)
        {
          file.deleteOnExit();
View Full Code Here

        output.setFormat( Format.getPrettyFormat() );

        try
        {
            StringWriter res = new StringWriter();
            output.output( root, res );

            return res.toString();
        }
        catch( IOException e )
        {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.