Package de.odysseus.staxon.xml

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


  public void testEscapeAttribute() throws Exception {
    StringWriter result = new StringWriter();
    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


  public void testAttributes() throws Exception {
    StringWriter result = new StringWriter();
    XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
    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.setDefaultNamespace("http://foo");
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeEmptyElement("bar", "bob", "http://bar");
    writer.writeNamespace("bar", "http://bar");
    writer.writeAttribute("jane", "dolly");
    writer.writeCharacters("hello");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><alice><bar:bob xmlns:bar=\"http://bar\" jane=\"dolly\"/>hello</alice>", result.toString());
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.