Package nu.xom

Examples of nu.xom.Serializer


        }
       
        try {
          Builder parser = new Builder();
          Document doc = parser.build(args[0]);
          Serializer serializer = new Serializer(System.out, "ISO-8859-1");
          serializer.setIndent(4);
          serializer.setMaxLength(64);
          serializer.setPreserveBaseURI(true);
          serializer.write(doc);
          serializer.flush();
        }
        catch (ParsingException ex) {
          System.out.println(args[0] + " is not well-formed.");
          System.out.println(ex.getMessage());
        }
View Full Code Here


      for (int year=1977; year <= 2006; year++) {
        setAmount(lineItem, String.valueOf(year), record);
      }
    }

    Serializer serializer = new Serializer(out, "UTF-8");
    serializer.write(doc);
    serializer.flush();
       
  }
View Full Code Here

        }
    
        try {
            OutputStream out
              = new FileOutputStream("data_" + encoding + ".xml");
            Serializer serializer = new Serializer(out, encoding);
            serializer.setIndent(4);
            serializer.write(doc);
            serializer.flush();
            out.close();
        }
        catch (IOException ex) {
            ex.printStackTrace();  
        }
View Full Code Here

        }
       
        try {
          Builder parser = new Builder();
          Document doc = parser.build(args[0]);
          Serializer serializer = new WrappingSerializer(System.out, "ISO-8859-1");
          serializer.setIndent(4);
          serializer.setMaxLength(24);
          serializer.setPreserveBaseURI(true);
          serializer.write(doc);
          serializer.flush();
        }
        catch (ParsingException ex) {
          System.out.println(args[0] + " is not well-formed.");
          System.out.println(ex.getMessage());
        }
View Full Code Here

     
      // Read the document
      Document document = parser.build(args[0]);
     
      // Write it out again
      Serializer serializer = new Serializer(System.out);
      serializer.write(document);

    }
    catch (IOException ex) {
      System.out.println(
      "Due to an IOException, the parser could not encode " + args[0]
View Full Code Here

   
    public void testCRLFInAttributeValueWithLineSeparatorCR()
      throws IOException, ParsingException {  
       
        root.addAttribute(new Attribute("test", "\r\n"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setLineSeparator("\r");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("\r", result);
View Full Code Here

   
    public void testCRLFInAttributeValueWithLineSeparatorLF()
      throws IOException, ParsingException
       
        root.addAttribute(new Attribute("test", "\r\n"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setLineSeparator("\n");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("\n", result);
View Full Code Here

   
    public void testLFInAttributeValueWithLineSeparatorCRLF()
      throws IOException, ParsingException
       
        root.addAttribute(new Attribute("test", "\n"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setLineSeparator("\r\n");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("\r\n", result);
View Full Code Here

   
    public void testNotEscapeLinefeedInTextContent()
      throws IOException {

        root.appendChild("\r\n");
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.write(doc);
        out.close();
        String result = new String(out.toByteArray(), "ISO-8859-1");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<root>&#x0D;\n</root>\r\n",
          result
View Full Code Here

   
    public void testCRLFInAttributeValue()
      throws IOException, ParsingException

        root.addAttribute(new Attribute("test", "a\r\na"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("CRLF not escaped", "a\r\na", result);
View Full Code Here

TOP

Related Classes of nu.xom.Serializer

Copyright © 2018 www.massapicom. 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.