Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamWriter.writeComment()


                "You should not set the node type of a comment");
    }

    public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
        XMLStreamWriter writer = omOutput.getXmlStreamWriter();
        writer.writeComment(this.textValue.toString());
    }

    public void serializeAndConsume(OMOutputImpl omOutput)
            throws XMLStreamException {
        serialize(omOutput);
View Full Code Here


     * @throws XMLStreamException
     * @see #serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl)
     */
    public void serializeWithCache(OMOutputImpl omOutput) throws XMLStreamException {
        XMLStreamWriter writer = omOutput.getXmlStreamWriter();
        writer.writeComment(this.value);
        OMNode nextSibling = this.getNextSibling();
        if (nextSibling != null) {
            nextSibling.serializeWithCache(omOutput);
        }
    }
View Full Code Here

      for (Map.Entry<String, Collection<UnitTest>> testSuite : _testsByClass.entrySet()) {
        final String suite = baseSuite + '.' + testSuite.getKey();
        final String path = getOutputDir() + File.separatorChar + "TEST-" + suite + ".xml";
        final XMLStreamWriter out = writerFactory.createXMLStreamWriter(new FileOutputStream(path));
        out.writeStartDocument();
        out.writeComment("Generated by " + getClass().getName());
        out.writeStartElement("testsuite");
        out.writeAttribute("hostname", getHostName(testSuite.getValue()));
        out.writeAttribute("name", suite);
        out.writeAttribute("tests", Integer.toString(testSuite.getValue().size()));
        out.writeAttribute("errors", Integer.toString(getErrors(testSuite.getValue())));
View Full Code Here

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

  @Test
  public void testWriteComment() throws XMLStreamException {
    XMLStreamWriter writer = createXMLStreamWriter(false);
    writer.writeStartElement("foo");
    writer.writeComment("bar");
    writer.writeEndElement();
    writer.flush();
    Assert.assertEquals("<foo><!--bar--></foo>", writer.toString());
  }
View Full Code Here

                    try {
                        xmlStreamWriter.writeCharacters("\n");
                        String comment = comments.get(elementName);
                        if (comment != null) {
                            indent(xmlStreamWriter);
                            xmlStreamWriter.writeComment(comment);
                            xmlStreamWriter.writeCharacters("\n");
                            indent(xmlStreamWriter);
                        }
                    } catch (XMLStreamException ignored) {
                        // shouldn't happen
View Full Code Here

                    try {
                        xmlStreamWriter.writeCharacters("\n");
                        String comment = comments.get(elementName);
                        if (comment != null) {
                            indent(xmlStreamWriter);
                            xmlStreamWriter.writeComment(comment);
                            xmlStreamWriter.writeCharacters("\n");
                            indent(xmlStreamWriter);
                        }
                    } catch (XMLStreamException ignored) {
                        // shouldn't happen
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.