Package org.kapott.hbci.sepa.jaxb.pain_001_003_03

Examples of org.kapott.hbci.sepa.jaxb.pain_001_003_03.Document


    assertNotNull(out.toString());
  }
 
  @Test
  public void testCRNLEscaping() {
    Document doc = new Document();
    Element root = new Element("root");
    Element child1 = new Element("child1");
    Element child2 = new Element("child2");
    Text stuff = new Text("foo");
    root.addContent(child1);
    root.addContent(stuff);
    root.addContent(child2);
    doc.setRootElement(root);
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    String actual = xout.outputString(doc);
    String expect = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
        + "<root>\r\n"
        + "  <child1 />\r\n"
View Full Code Here


        outputString(ftfw,     root));
  }
 
  @Test
  public void testDocumentSimple() {
    Document content = new Document();
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
        outputString(fraw,     content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
        outputString(fcompact, content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
View Full Code Here

        outputString(ftfw,     content));
  }
 
  @Test
  public void testDocumentDocType() {
    Document content = new Document();
    content.setDocType(new DocType("root"));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE root>\n",
        outputString(fraw,     content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE root>\n",
        outputString(fcompact, content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE root>\n",
View Full Code Here

        outputString(ftfw,     content));
  }
 
  @Test
  public void testDocumentComment() {
    Document content = new Document();
    content.addContent(new Comment("comment"));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--comment-->\n",
        outputString(fraw,     content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--comment-->\n",
        outputString(fcompact, content));
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--comment-->\n",
View Full Code Here

    checkOutput(new DocType("root", "publicID", "systemID"), dec, dec, dec, dec, dec);
  }

  @Test
  public void testOutputDocumentSimple() {
    Document doc = new Document();
    doc.addContent(new Element("root"));
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String rtdec = "<root />";
    checkOutput(doc,
        xmldec + "\n" + rtdec + "\n",
        xmldec + "\n" + rtdec + "\n",
View Full Code Here

        xmldec + "\n" + rtdec + "\n");
  }

  @Test
  public void testOutputDocumentOmitEncoding() {
    Document doc = new Document();
    doc.addContent(new Element("root"));
    String xmldec = "<?xml version=\"1.0\"?>";
    FormatSetup setup = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setOmitEncoding(true);
View Full Code Here

        xmldec + "\n" + rtdec + "\n");
  }

  @Test
  public void testOutputDocumentOmitDeclaration() {
    Document doc = new Document();
    doc.addContent(new Element("root"));
    FormatSetup setup = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setOmitDeclaration(true);
      }
View Full Code Here

   */
  private static final Document process(final JDOMFactory factory,
      final XMLEventReader events) throws JDOMException {
    try {

      final Document document = factory.document(null);
      Element current = null;

      XMLEvent event = events.peek();

      if (XMLStreamConstants.START_DOCUMENT != event.getEventType()) {
        throw new JDOMException("JDOM requires that XMLStreamReaders " +
            "are at their beginning when being processed.");
      }



      while (event.getEventType() != XMLStreamConstants.END_DOCUMENT) {
        if (event.isStartDocument()) {
          document.setBaseURI(event.getLocation().getSystemId());
          document.setProperty("ENCODING_SCHEME",
              ((javax.xml.stream.events.StartDocument)event).getCharacterEncodingScheme());
          document.setProperty("STANDALONE", String.valueOf(
              ((javax.xml.stream.events.StartDocument)event).isStandalone()));
          //            document.setProperty("ENCODING",
          //                ((StartDocument)event).getEncoding());
        } else if (event instanceof javax.xml.stream.events.DTD) {
          //List<?> list = (List<?>)reader.getProperty("javax.xml.stream.entities");
          //System.out.println(list);
          final DocType dtype = DTDParser.parse(((javax.xml.stream.events.DTD)event).getDocumentTypeDeclaration(), factory);
          document.setDocType(dtype);
        } else if (event.isStartElement()) {
          final Element emt = processElement(factory, event.asStartElement());
          if (current == null) {
            document.setRootElement(emt);
            final DocType dt = document.getDocType();
            if (dt != null) {
              dt.setElementName(emt.getName());
            }
          } else {
            current.addContent(emt);
          }
          current = emt;
        } else if (event.isCharacters()) {
          final Characters chars = event.asCharacters();
          if (chars.isCData()) {
            current.addContent(factory.cdata(
                ((Characters)event).getData()));
          } else {
            current.addContent(factory.text(
                ((Characters)event).getData()));
          }
        } else if (event instanceof javax.xml.stream.events.Comment) {
          final Comment comment = factory.comment(
              ((javax.xml.stream.events.Comment)event).getText());
          if (current == null) {
            document.addContent(comment);
          } else {
            current.addContent(comment);
          }
        } else if (event.isEntityReference()) {
          current.addContent(factory.entityRef(
              ((javax.xml.stream.events.EntityReference)event).getName()));
        } else if (event.isProcessingInstruction()) {
          final ProcessingInstruction pi = factory.processingInstruction(
              ((javax.xml.stream.events.ProcessingInstruction)event).getTarget(),
              ((javax.xml.stream.events.ProcessingInstruction)event).getData());
          if (current == null) {
            document.addContent(pi);
          } else {
            current.addContent(pi);
          }
        } else if (event.isEndElement()) {
          current = current.getParentElement();
View Full Code Here

  public void testOutputDocumentFull() {
    DocType dt = new DocType("root");
    Comment comment = new Comment("comment");
    ProcessingInstruction pi = new ProcessingInstruction("jdomtest", "");
    Element root = new Element("root");
    Document doc = new Document();
    doc.addContent(dt);
    doc.addContent(comment);
    doc.addContent(pi);
    doc.addContent(root);
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String dtdec = "<!DOCTYPE root>";
    String commentdec = "<!--comment-->";
    String pidec = "<?jdomtest?>";
    String rtdec = "<root />";
View Full Code Here

  @Test
  public void testDeepNesting() {
    // need to get beyond 16 levels of XML.
    DocType dt = new DocType("root");
    Element root = new Element("root");
    Document doc = new Document();
    doc.addContent(dt);
    doc.addContent(root);
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String dtdec = "<!DOCTYPE root>";
    String lf = "\n";
   
    StringBuilder raw = new StringBuilder();
View Full Code Here

TOP

Related Classes of org.kapott.hbci.sepa.jaxb.pain_001_003_03.Document

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.