Package de.odysseus.staxon.xml

Examples of de.odysseus.staxon.xml.SimpleXMLStreamWriter.writeEndDocument()


    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeCharacters("bob");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice>bob</alice>", result.toString());
  }
 
  /**
 
View Full Code Here


    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeComment("bob");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice><!--bob--></alice>", result.toString());
  }

View Full Code Here

    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeCharacters("<>&\"'");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice>&lt;&gt;&amp;\"'</alice>", result.toString());
  }

  /**
 
View Full Code Here

    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeCData("<>&\"'");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice><![CDATA[<>&\"']]></alice>", result.toString());
  }

  /**
 
View Full Code Here

    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeAttribute("escape", "<>&\"'");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice escape=\"&lt;&gt;&amp;&quot;'\"></alice>", result.toString());
  }

  /**
 
View Full Code Here

    writer.writeEndElement();
    writer.writeStartElement("david");
    writer.writeCharacters("edgar");
    writer.writeEndElement();
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice><bob>charlie</bob><david>edgar</david></alice>", result.toString());
  }
 
  /**
 
View Full Code Here

    writer.writeEndElement();
    writer.writeStartElement("bob");
    writer.writeCharacters("david");
    writer.writeEndElement();
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice><bob>charlie</bob><bob>david</bob></alice>", result.toString());
  }

  /**
 
View Full Code Here

    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeAttribute("charlie", "david");
    writer.writeCharacters("bob");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice charlie=\"david\">bob</alice>", result.toString());
  }
 
  /**
 
View Full Code Here

    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeDefaultNamespace("http://some-namespace");
    writer.writeCharacters("bob");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice xmlns=\"http://some-namespace\">bob</alice>", result.toString());
  }

  /**
 
View Full Code Here

    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, true);
    writer.writeStartDocument();
    writer.writeStartElement("http://some-namespace", "alice");
    writer.writeCharacters("bob");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice xmlns=\"http://some-namespace\">bob</alice>", result.toString());
  }

  @Test(expected = XMLStreamException.class)
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.