Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLStreamWriter2.writeCharacters()


            sw.writeStartElement("root");
            // Should be fine now
            sw.writeCharacters("Text that should be ok");
            sw.writeStartElement("branch");
            // Also, all-whitespace is ok in non-mixed too
            sw.writeCharacters("\t \t   \r   \n");
            sw.writeEndElement();
            sw.writeEndElement();
            sw.writeEndDocument();
        }
    }
View Full Code Here


            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            // Should get validation exception here:
            try {
                sw.writeCharacters("Illegal text!");
                fail("Expected a validation exception for non-whitespace text output on non-mixed element content");
            } catch (XMLValidationException vex) {
                // expected...
            }
        }
View Full Code Here

            // Then with any text (even just white space):
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeCharacters(" ");
                fail(modeDesc+" Expected a validation exception when trying to any text into EMPTY content model");
            } catch (XMLValidationException vex) { }
            sw.close();

            // Then CDATA
View Full Code Here

            // First simplest case
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeStartElement("leaf");
            sw.writeCharacters("whatever");
            sw.writeEndElement();
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();
View Full Code Here

            boolean repairing = (i == 2);

            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, SIMPLE_DTD, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeStartElement("branch");
            sw.writeEndElement();
            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
View Full Code Here

            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeStartElement("branch");
            sw.writeEndElement();
            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeEmptyElement("end");
            sw.writeAttribute("endAttr", "value");
View Full Code Here

            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeEmptyElement("end");
            sw.writeAttribute("endAttr", "value");
            sw.writeCharacters("\n"); // imitating indentation
            sw.writeEndElement(); // for root
        }
    }

    public void testInvalidStructure()
View Full Code Here

           
            // Let's try omitting the end element, first...

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, SIMPLE_DTD, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeStartElement("branch");
            sw.writeEndElement();
            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
View Full Code Here

            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeStartElement("branch");
            sw.writeEndElement();
            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeCharacters("\n"); // imitating indentation
            try {
View Full Code Here

            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeCharacters("\n"); // imitating indentation
            try {
                sw.writeEndElement(); // for root
                fail(modeDesc+" Expected a validation exception when omitting non-optional <end> element");
            } catch (XMLValidationException vex) {
                // expected...
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.